[英]iOS 7 Landscape only app can't access photo library
I have a landscape only app and whenever I access the Photo library , app would crash (because UIImagePickerViewController
is trying to load in portrait mode). 我有一个仅限风景的应用程序,每当我访问照片库时,该应用程序都会崩溃(因为
UIImagePickerViewController
试图以纵向模式加载)。 App works fine in iOS 5
and 6
. 该应用程序在
iOS 5
和6
运行良好。
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation'
, reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES' 由于未捕获的异常
'UIApplicationInvalidInterfaceOrientation'
终止了应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回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
Unfortunately, it seems that UIImagePickerViewController will only work in portrait mode. 不幸的是,似乎UIImagePickerViewController将仅在纵向模式下工作。 Only way I have found to fix this problem is to add Portrait mode support to app in plist but limit all other views to only support landscape.
我发现解决此问题的唯一方法是向纵向列表中的应用程序添加肖像模式支持,但将所有其他视图限制为仅支持横向。
Add below to all your views you don't want in portrait: 在您想要的所有纵向视图中添加以下内容:
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
Credit for this answer goes to iOS 7 Landscape only app can't access photo library 此答案归功于iOS 7 Landscape only应用程序无法访问照片库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.