开发者

Forcing UIImagePickerController to shoot video in landscape mode

I've got a mostly-portrait iPhone application that needs to shoot some video, and I'd like to gently encourage (okay, force) users to shoot that video in landscape mode.

I've tried creating a UIViewController with ShouldAutorotateToInterfaceOrientation overridden to return false, and appropriate CGAffineTransforms on its view, but it has no effect -- I assume because the view is out of the picture once you call PresentModalViewController to display the UIImagePickerCont开发者_JS百科roller. The controls always show up in the same place, and the switch-to-front-camera control still moves around when I rotate the phone.

Any suggestions? I'd settle for definitive evidence that this isn't possible, though I'm not sure my boss would.


Try calling UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications() in your AppDelegate.

Then in the ViewDidLoad() method of your UIImagePickerController, add an observer by doing the following:

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

where DeviceRotated is

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜