2010-11-10 113 views
2

我有一个大部分肖像的iPhone应用程序需要拍摄一些视频,我想轻轻鼓励(好的,强制)用户以横向模式拍摄该视频。强制UIImagePickerController以横向模式拍摄视频

我试图创建一个UIViewControllerShouldAutorotateToInterfaceOrientation重写返回false,并在它认为适当CGAffineTransforms,但它没有任何效果 - 我想是因为视图中出来的图片,一旦你打电话PresentModalViewController显示UIImagePickerController 。这些控件始终显示在同一个地方,而且当旋转手机时,切换到前端摄像头控制仍会左右移动。

有什么建议吗?我会确定这是不可能的,但我不确定我的老板会这么做。

回答

1

尝试在您的AppDelegate中调用UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications()

public override void ViewDidLoad() 
{ 
    base.ViewDidLoad(); 
    NSNotificationCenter.DefaultCenter.AddObserver("UIDeviceOrientationDidChangeNotification", DeviceRotated); 
} 

其中DeviceRotated是

private void DeviceRotated(NSNotification notification) 
{ 
    button.Transform = CGAffineTransform.MakeRotation(1.5f); 
} 

在你的UIImagePickerController的viewDidLoad中()方法

然后,通过执行以下操作添加一个观察者