我有一个仅限横向应用程序,每当我访问照片库时,应用程序都会崩溃(因为UIImagePickerViewController
正试图以纵向模式加载)。应用可在iOS 5
和6
中正常使用。
由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'
而终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且应该返回YES'
*** First throw call stack:
(
0 CoreFoundation 0x0303c5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x024028b6 objc_exception_throw + 44
2 CoreFoundation 0x0303c3bb +[NSException raise:format:] + 139
3 UIKit 0x0108b7b2 -[UIViewController __supportedInterfaceOrientations] + 509
4 UIKit 0x0108b7de -[UIViewController __withSupportedInterfaceOrientation:apply:] + 34
5 UIKit 0x0108be52 -[UIViewController setInterfaceOrientation:] + 139
6 UIKit 0x01080ca8 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 946
7 UIKit 0x00fcdb48 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1530
8 UIKit 0x00fcd847 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 761
9 UIKit 0x00fc5070 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 162
10 UIKit 0x00fc4ef8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
11 UIKit 0x00fd0031 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
12 UIKit 0x00fc3521 -[UIView(Hierarchy) addSubview:] + 56
13 UIKit 0x0128cc3f -[UINavigationTransitionView transition:fromView:toView:] + 501
14 UIKit 0x0128ca42 -[UINavigationTransitionView transition:toView:] + 55
15 UIKit 0x010a23d7 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3186
16 UIKit 0x010a272c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
17 UIKit 0x010a3349 -[UINavigationController __viewWillLayoutSubviews] + 57
18 UIKit 0x011dc39d -[UILayoutContainerView layoutSubviews] + 213
19 UIKit 0x00fd2dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
20 libobjc.A.dylib 0x0241481f -[NSObject performSelector:withObject:] + 70
21 QuartzCore 0x00d6872a -[CALayer layoutSublayers] + 148
22 QuartzCore 0x00d5c514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
23 QuartzCore 0x00d5c380 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
24 QuartzCore 0x00cc4156 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
25 QuartzCore 0x00cc54e1 _ZN2CA11Transaction6commitEv + 393
26 QuartzCore 0x00cc5bb4 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
27 CoreFoundation 0x0300453e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
28 CoreFoundation 0x0300448f __CFRunLoopDoObservers + 399
29 CoreFoundation 0x02fe23b4 __CFRunLoopRun + 1076
30 CoreFoundation 0x02fe1b33 CFRunLoopRunSpecific + 467
31 CoreFoundation 0x02fe194b CFRunLoopRunInMode + 123
32 GraphicsServices 0x032969d7 GSEventRunModal + 192
33 GraphicsServices 0x032967fe GSEventRun + 104
34 UIKit 0x00f6894b UIApplicationMain + 1225
35 Kickass 0x000027ad main + 141
36 Kickass 0x00002715 start + 53
37 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
答案 0 :(得分:0)
不幸的是,似乎UIImagePickerViewController只能在纵向模式下工作。 我找到解决此问题的唯一方法是在plist中为app添加Portrait模式支持,但将所有其他视图限制为仅支持landscape。
在下面添加您不想要的所有视图:
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}