开发者

Orientation in iPhone

开发者 https://www.devze.com 2023-01-21 16:39 出处:网络
I have been working for iphone for about like 1 month and i want to开发者_StackOverflow中文版 know that is their any method by which we can set the orientation of the components, like when the device

I have been working for iphone for about like 1 month and i want to开发者_StackOverflow中文版 know that is their any method by which we can set the orientation of the components, like when the device is turned in landscape left or right or in portrait mode then the components must set their view accordingly.

Please help me out regarding this Thank You


Override shouldAutorotateToInterfaceOrientation in a view controller.

// MyViewController.m
...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ( [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait )
    {
        // If the device orientation is portrait, do stuff here.
    }

    else if ( [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscape )
    {
        // If the device orientation is landscape, do stuff here.
    }
}
...
0

精彩评论

暂无评论...
验证码 换一张
取 消