NSException:“因未捕获的异常而终止应用程序'UIApplicationInvalidInterfaceOrientation',原因:......”

时间:2015-08-06 21:49:50

标签: ios swift uiinterfaceorientation autorotate

这是来自用swift编写的iPhone应用程序:

*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', 
reason: 'Supported orientations has no common orientation with the application, 
and [UICompatibilityInputViewController shouldAutorotate] is returning YES
*** First throw call stack:
(0x1836984d0 0x198107f9c 0x183698418 0x188d7a1d0 0x188d833dc 0x188d83354     
0x188d81e3c 0x188cfe8fc 0x188cfdc0c 0x184581220 0x188cfda90 0x188d0ad08 
0x1895558e4 0x189556944 0x188d11af8 0x189556740 0x1895505d4 0x188dccd90 
0x18939b3dc 0x18939b5ec 0x18d43bb20 0x18d43bea0 0x18364fd6c 0x18364f800 
0x18364d500 0x18357d280 0x18e6f40cc 0x188d6adf8 0x100120d94 0x19894a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

我正在构建一个应用程序,要求手机保持'PortraitUpsideDown',以便后置摄像头始终位于底部。为了反映这一点,我的Info.plist包括:

<key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>

该应用程序很小,并且有一个视图控制器,其中包括

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.PortraitUpsideDown
}

override func shouldAutorotate() -> Bool {
   return false
}

该应用程序有点自然终止。我可以在不同的时间内构建和使用应用程序,即我无法“导致”错误发生。

1 个答案:

答案 0 :(得分:1)

方向由三个文件决定:

  1. 的Info.plist

  2. 查看控制器

  3. 的AppDelegate

  4. curl_exec必须包含

    Info.plist

    <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortraitUpsideDown</string> </array> 必须包含

    ViewController.swift

    override func shouldAutorotate() -> Bool { return false } override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation { return UIInterfaceOrientation.PortraitUpsideDown } 必须包含

    AppDelegate.swift