[英]Orientation Issues in ios 6.0
我已经在iPhone和iPad的纵向模式下完成了我的应用程序,现在在横向模式下也需要相同的应用程序,iPhone和iPad都只使用xib。并且以编程方式创建了一些UI。 刚才我正在使用此代码:
-(NSUInteger)supportedInterfaceOrientations
{
// return your mask here e.g.:
if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
return UIInterfaceOrientationMaskPortrait;
else
return UIInterfaceOrientationMaskLandscape;
}
但是它不能正常工作,所以有人可以帮助我吗……?
将此代码更改为以下内容:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
}
并添加以下内容:
- (BOOL) shouldAutorotate
{
return YES;
}
终于我做到了,现在正在使用这段代码;
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation持续时间:(NSTimeInterval)duration {if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){// NSLog(@“ Landscape left”);
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"Landscape right");
} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
// NSLog(@"Portrait");
} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
// NSLog(@"Upside down");
}
}对于所有人,Thanq所有人,都工作得很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.