
我在横向模式下有一个视图,我正在尝试打开一个仅限肖像的视图控制器.每次我尝试打开它,应用程序崩溃.
我已阅读此official apple answer,基本上建议执行以下 *** 作:
在app委托中:
@implementation AppDelegate-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrIEntationsForWindow:(UIWindow *)window{ if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad) return UIInterfaceOrIEntationMaskAll; else /* iphone */ return UIInterfaceOrIEntationMaskAllButUpsIDeDown;} 在我的控制器中:
-(NSUInteger)supportedInterfaceOrIEntations{ return UIInterfaceOrIEntationMaskLandscape;} 所以我有,但我仍然得到这个崩溃消息:
Terminating app due to uncaught exception 'UIApplicationInvalIDInterfaceOrIEntation',reason: 'Supported orIEntations has no common orIEntation with the application,and [PUUIAlbumListVIEwController shouldautorotate] is returning YES
在项目常规设置中,我有以下(不应根据苹果的答案进行更改):
我可以看到这些函数实际上被调用但没有任何帮助.
有什么想法吗?
我之前读过的一些问题:
How to force a UIViewController to Portrait orientation in iOS 6
iOS6: supportedInterfaceOrientations not working (is invoked but the interface still rotates)
Supported orientations has no common orientation with the application,and shouldAutorotate is returning YES’
解决方法 概要:应用程序(_:,supportedInterfaceOrIEntationsForWindow) – > Int会覆盖General>部署信息因此,一旦在app委托中提供supportedInterfaceOrIEntationsForWindow,就可以完全忽略该.pList.请参阅有关UIInterfaceOrIEntationMaskPortrait的说明.在Obj-C和Swift中尝试了上面的代码,只有我得到的…
‘UIApplicationInvalIDInterfaceOrIEntation’,reason: ‘Supported orIEntations has no common orIEntation with the application,and [VIEwController shouldautorotate] is returning YES’
…那时候:
>使用UIInterfaceOrIEntationPortrait而不是UIInterfaceOrIEntationMaskPortrait(mask是这里的关键字)
>或supportedInterfaceOrIEntations返回未在supportedInterfaceOrIEntationsForWindow中列出的掩码
A.将此块放在采用UIApplicationDelegate协议的类中(通常是AppDelegate.m或AppDelegate.swift):
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrIEntationsForWindow:(UIWindow *)window{ if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad) return UIInterfaceOrIEntationMaskAll; else /* iphone */ return UIInterfaceOrIEntationMaskAllButUpsIDeDown;} supportedInterfaceOrIEntations将覆盖部署信息,并允许在运行时动态区分iPhone和iPad.
B.将此块放在您想要特定行为的UIVIEwController子类中(通常是CustomVIEwController.m或CustomVIEwController.swift):
OBJ-C
-(NSUInteger)supportedInterfaceOrIEntations{ return UIInterfaceOrIEntationMaskPortrait;} 迅速
overrIDe func supportedInterfaceOrIEntations() -> Int { let supported = UIInterfaceOrIEntationMask.Portrait.rawValue return Int(supported)} 经过测试的iOS 8.4
总结以上是内存溢出为你收集整理的iOS错误:支持的方向与应用程序(iPhone)没有共同的方向全部内容,希望文章能够帮你解决iOS错误:支持的方向与应用程序(iPhone)没有共同的方向所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)