我正在使用 Wikitude SDK 中的增强现实构建一个颤振应用程序。它基于此示例应用程序构建: https ://github.com/Wikitude/wikitude-flutter-plugin-examples
由于我强制我的应用程序方向为 LandscapeLeft 和 LandscapeRight,因此我在 iOS 上的相机视图出现问题,其中相机随方向旋转。在 Android 上,相机不随方向旋转。
这是 MyApp Widget build() 中的方向设置:
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
这是 /ios/Runner/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>UIRequiresFullScreen</key>
<true/>
负责视图的小部件如下所示:
@override
Widget build(BuildContext context) {
if(defaultTargetPlatform == TargetPlatform.android) {
return AndroidView(
viewType: 'architectwidget',
onPlatformViewCreated: onPlatformViewCreated,
creationParams: configuration,
creationParamsCodec: const StandardMessageCodec(),
);
} else if(defaultTargetPlatform == TargetPlatform.iOS) {
return UiKitView(
viewType: 'architectwidget',
onPlatformViewCreated: onPlatformViewCreated,
creationParams: configuration,
creationParamsCodec: const StandardMessageCodec(),
);
}
return new Text('$defaultTargetPlatform is not yet supported by this plugin');
}
无论我如何旋转设备,我都希望相机视图相同。在我添加方向设置 MyApp Widget build() 和 /ios/Runner/info.plist 之前,我的应用程序可以旋转到纵向(我已删除)并且相机没有遵循应用程序的方向。所以在强制横向方向之前,相机视图按预期旋转。
如何在不影响相机视图方向的情况下强制方向为横向?