强制 UIImagePickerController 以横向模式拍摄视频

发布于 2024-10-01 03:05:02 字数 424 浏览 0 评论 0原文

我有一个主要是纵向的 iPhone 应用程序,需要拍摄一些视频,我想温和地鼓励(好吧,强制)用户以横向模式拍摄该视频。

我尝试创建一个 UIViewController ,并覆盖 ShouldAutorotateToInterfaceOrientation 以返回 false,并在其视图上创建适当的 CGAffineTransforms ,但它没有效果 - 我假设是因为一旦调用 PresentModalViewController 显示 UIImagePickerController,视图就会超出图片。这些控件始终显示在同一位置,并且当我旋转手机时,切换到前置摄像头控件仍然会移动。

有什么建议吗?我愿意接受确凿的证据来证明这是不可能的,尽管我不确定我的老板会不会。

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 UIImagePickerController. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷血 2024-10-08 03:05:02

尝试在 AppDelegate 中调用 UIDevice.CurrentDevice.BeginGenerateDeviceOrientationNotifications()

然后在 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);
}

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文