[英]Issues in iOS 6.0 rotation
我正在制作一个既可以纵向又可以横向的应用程序。 对于iOS 5.0
我通过以下方式添加视图,即
-(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
if(((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeRight)))
{
productname.frame=CGRectMake(240, 97, 106, 20);
self.view = landscapeView;
}
else if
(((interfaceOrientation == UIInterfaceOrientationPortrait) ||
(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))){
productname.frame=CGRectMake(153, 151, 106, 20);
self.view = portraitView;
}
return YES;
}
但是对于iOS 6.0
我采用了以下两种定向方法:
我实际上需要一种在设备旋转期间必须触发的方法。 如果有人有主意,请告诉我。 我已经浪费了很多时间。
非常感谢。
我正在使用带有以下代码的UINavigationController子类:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
if (self.topViewController.presentedViewController) {
return self.topViewController.presentedViewController.supportedInterfaceOrientations;
}
return self.topViewController.supportedInterfaceOrientations;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return self.topViewController.preferredInterfaceOrientationForPresentation;
}
对我来说非常完美
并在AppDelegate.m文件中:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [UIDevice isIpad] ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskAllButUpsideDown;
}
采用
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.