我的应用程序处于横向模式,我想打开画廊并选择视频,但我收到错误消息。是否有任何方式使用UIImagePickerController横向模式或任何其他方式?有可能在iOS横向模式下使用UIImagePickerController?
0
A
回答
0
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
这应该有效。如果你的应用只允许肖像。你必须在应用程序委托中做一些额外的工作。您需要设置一个布尔属性,将其称为restrictRotation。然后包括AppDelegate.h在你的类,并设置restrictRotation为真时,你需要再旋转它
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(self.restrictRotation)
return UIInterfaceOrientationMaskPortrait;
else
return UIInterfaceOrientationMaskAll;
}
在类
- (void) orientationChanged:(NSNotification *)note
{
UIDevice * device = note.object;
switch(device.orientation)
{
case UIDeviceOrientationPortrait:
//do stuff
break;
case UIDeviceOrientationLandscapeLeft:
//do stuff
break;
case UIDeviceOrientationLandscapeRight:
//do stuff
break;
default:
break;
};
}
-(void) restrictRotation:(BOOL) restriction
{
AppDelegate* appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
appDelegate.restrictRotation = restriction;
}
这应该有助于
0
在你ViewController.m
:
使图像选取器控制器的子类(ViewController)
@interface ViewController : UIImagePickerController
@end
@implementation ViewController
// Disable Landscape mode.
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
@end
使用下面的代码:
UIImagePickerController* picker = [[ViewController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
// etc.... do like Just as Default ImagePicker Controller
但要确保你在部署信息查询肖像,
因为UIImagePickerController
只支持肖像模式。 如果您不支持纵向“全局”,图像选择器将因为没有可用的方向而崩溃。
相关问题
- 1. 横向模式下的UIImagepickercontroller
- 2. 是否有可能在iphone中以横向模式显示UIImagePickerController?
- 3. iOS应用在横向模式下
- 4. 横向使用UIImagePickerController
- 5. 如何强制UIImagePickerController仅在横向模式下拍摄图像....?
- 6. 在横向模式下使用Core Motion
- 7. 在Swift 2.0中以横向模式使用UIImagePickerController
- 8. UIImagePickerController在iphone中使用横向模式的摄像头选项
- 9. 横向布局不能在横向模式下工作
- 10. IOS:在横向模式下使用avcam进行视频录制?
- 11. ImageView在横向模式下
- 12. 在横向模式下
- 13. Youtube视频不能在横向模式下播放iOS 8
- 14. 横向的UIImagePickerController
- 15. 强制iOS应用程序在横向模式下启动
- 16. 在横向模式下制作iOS应用程序
- 17. iOS 8 - 在横向模式下启动应用程序
- 18. IOS纵向和横向模式
- 19. 在横向和纵向模式下使用ScrollViewer正确滚动
- 20. Fullpage.js在横向模式下无法在iOS上正确缩放
- 21. 印刷在IE11在横向模式下
- 22. 仅在横向模式下启动应用程序,并在横向模式下锁定应用程序
- 23. UIActionSheet不在横向模式下旋转?
- 24. 在横向模式下打开视图
- 25. 在横向模式下启动屏幕
- 26. 在横向模式下打印vb.net
- 27. UIDeviceOrientation未知在横向模式下
- 28. 在横向模式下不缩放?
- 29. 在横向模式下获取htmlpage
- 30. Startactivity的结果,在横向模式下
[检查此链接的景观应用](http://stackoverflow.com/questions/12551247/autorotate-a-single-uiviewcontroller-in-ios-6-with-uitabbar) &HTTP://计算器.COM /问题/ 19374237 /使用-的UIImagePickerController式景观的方向 –