我收到此错误,并且不知道可能导致它的原因。这种情况发生在iOS 8.2的iPhone和iPad上。
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_PROTECTION_FAILURE at 0x00554ff4 raw
0 libobjc.A.dylib lookUpImpOrForward + 3
4 libobjc.A.dylib -[NSObject respondsToSelector:] + 38
5 UIKit -[UIWindow _supportedInterfaceOrientationsForRootViewController] + 56
6 UIKit -[_UIFallbackPresentationViewController supportedInterfaceOrientations] + 60
7 UIKit -[_UIFallbackPresentationViewController supportedInterfaceOrientations] + 60
...
510 UIKit -[_UIFallbackPresentationViewController supportedInterfaceOrientations] + 60
我读到有些人认为这应该解决这些问题,但它没有用。
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ( IDIOM == IPAD ) {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
答案 0 :(得分:2)
我最后联系了苹果这个问题。根据他们与游戏中心有关。苹果改变了一些东西,游戏中心初始化的旧方式会产生随机崩溃。在我的游戏中添加了Game Center Manger,这些随机崩溃停止了。
答案 1 :(得分:1)
以下代码适用于我。
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskLandscape;
}
如果它没有解决您的问题,我认为代码的其他部分是错误的。
您可以创建一个空项目并尝试代码(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
,看看问题是否恰好是为了隔离bugger
检查变量 IDIOM 并在代码中正确设置 IPAD
#define IDIOM UI_USER_INTERFACE_IDIOM()
#define IPAD UIUserInterfaceIdiomPad
EXC_BAD_ACCESS 是由非法内存访问引起的,您可能正在访问已解除分配的变量。
检查所有指针,尤其是对象指针,以确保它们正确 初始化。如果您使用的是 xib ,请确保您已正确设置, 与所有必要的联系。
如果这些都不起作用,那么尝试使用NSLog() 找到错误 语句并找到导致错误的行然后设置 断点和检查其中的所有变量和对象,看看有什么不符合预期。
希望这会有所帮助。 如果问题仍然没有解决,请随时问我
答案 2 :(得分:-1)
您必须在您的Viewcontroller
中添加以下方法-(NSUInteger)supportedInterfaceOrientations{
return yes for supported orientations
}