提问人:André Haupt 提问时间:1/21/2022 最后编辑:André Haupt 更新时间:1/21/2022 访问量:210
Flutter: ImagePicker UIApplicationInvalidInterfaceOrientation 异常
Flutter: ImagePicker UIApplicationInvalidInterfaceOrientation Exception
问:
当我在仅横向(左右)方向的应用程序上执行此调用时,我正在使用image_picker并在运行iOS 10.4的iPad上遇到以下错误。ImagePicker().pickImage(source: ImageSource.gallery)
这在运行 14+ 的 iOS 模拟器上工作正常。
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'
*** First throw call stack:
(0x1cef7b3d 0x1c17f067 0x1cef7a85 0x221960b9 0x2219ee67 0x2219ee07 0x2219d427 0x22120aeb 0x221208a9 0x221208a9 0x221208a9 0x2211fee5 0x2211fd71 0x2212b27f 0x2212ac03 0x22218757 0x22217b3f 0x2245cc43 0x223a2983 0x22395c93 0x221178bd 0x1ceb3803 0x1ceb1a55 0x1ceb2017 0x1ce051af 0x1ce04fd1 0x1e5afb41 0x22187a53 0xbe7f7 0x1c5f24eb)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'
terminating with uncaught exception of type NSException
(lldb)
我确实使用以下命令指定了应用程序方向,但我发现无论是否使用它,都会发生错误。
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight])
.then((_){
runApp(MyApp());
}
);
在我的文件中选择了相应的设备方向。Info.plist
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
更新1:
使用相机时,使用以下命令,选择器在iOS 10.4上工作正常。
ImagePicker().pickImage(source: ImageSource.camera)
答:
1赞
André Haupt
1/21/2022
#1
事实证明,数组中必须有该项。Info.plist
UIInterfaceOrientationPortrait
UISupportedInterfaceOrientations
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
(在我的实例中,我也必须将其添加到数组中。UISupportedInterfaceOrientations~iPad
评论