【发布时间】:2015-05-14 05:59:45
【问题描述】:
UIImagePickerController 应该横向打开吗?我尝试使用类别,但它不起作用。如何将方向固定为UIImagePickerController?
【问题讨论】:
标签: ios uiimagepickercontroller uiinterfaceorientation
UIImagePickerController 应该横向打开吗?我尝试使用类别,但它不起作用。如何将方向固定为UIImagePickerController?
【问题讨论】:
标签: ios uiimagepickercontroller uiinterfaceorientation
你应该使用 UIPopoverController 在横向模式下显示 ImagePickerController
-(void)showImagePicker:(id)sender
{
UIButton *button = (UIButton *)sender; // button is on which user will tap to show image picker
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.allowsEditing = YES;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
[self.popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
【讨论】:
UIImagePickerController 类仅支持纵向模式。此类旨在按原样使用,不支持子类化。
【讨论】:
这很容易。尝试创建 UIImagePickerController 的自定义类。覆盖其中的supportedInterfaceOrientations方法:
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate{
return YES;
}
【讨论】: