Orientation in iPhone
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.
}
}
...
精彩评论