我有一个主要是纵向的 iPhone 应用程序需要拍摄一些视频,我想温和地鼓励(好吧,强制)用户以横向模式拍摄该视频。
我尝试创建一个 UIViewController
并覆盖 ShouldAutorotateToInterfaceOrientation
以返回 false,并在其 View 上使用适当的 CGAffineTransforms
,但它没有任何效果-- 我假设是因为当您调用 PresentModalViewController
来显示 UIImagePickerController
时, View 不在画面中。控件始终显示在同一个位置,并且当我旋转手机时,切换到前置摄像头的控件仍然会四处移动。
有什么建议吗?我愿意接受确凿的证据证明这是不可能的,尽管我不确定我的老板是否会这样做。
最佳答案
尝试在您的 AppDelegate 中调用 UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications()
。
然后在 UIImagePickerController 的 ViewDidLoad() 方法中,通过执行以下操作添加观察者:
public override void ViewDidLoad()
{
base.ViewDidLoad();
NSNotificationCenter.DefaultCenter.AddObserver("UIDeviceOrientationDidChangeNotification", DeviceRotated);
}
DeviceRotated 在哪里
private void DeviceRotated(NSNotification notification)
{
button.Transform = CGAffineTransform.MakeRotation(1.5f);
}
关于iphone - 强制 UIImagePickerController 以横向模式拍摄视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4140493/