PF1*_*PF1 23 iphone cocoa-touch landscape image uiimagepickercontroller
我一直在寻找答案,但无法想出任何答案.显然,iPhone SDK 3.0使得UIImagePickerController可以以横向模式显示 - 但我找不到任何允许这样做的方法.我认为如果应用程序默认情况下是横向的,它会自动调整图像控制器,但这对我不起作用.
谢谢你的帮助!
Ari*_*sky 15
不需要子类; 简单地覆盖modalPresentationStyle属性.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.modalPresentationStyle = UIModalPresentationFormSheet;
[viewController presentViewController:picker animated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud)
era*_*uki 13
我没有检查这是否违法,但它对我有用.如果您希望UIImagePickerController以横向方向代码启动(并保持):
//Initialize picker
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
//set Device to Landscape. This will give you a warning. I ignored it.
//warning: 'UIDevice' may not respond to '-setOrientation:'
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
//Set Notifications so that when user rotates phone, the orientation is reset to landscape.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
//Refer to the method didRotate:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
//Set the picker source as the camera
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
//Bring in the picker view
[self presentModalViewController:picker animated:YES];
Run Code Online (Sandbox Code Playgroud)
方法didRotate:
- (void) didRotate:(NSNotification *)notification
{
//Maintain the camera in Landscape orientation
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
}
Run Code Online (Sandbox Code Playgroud)
如果你只是需要摆脱警告尝试
@interface UIDevice ()
-(void)setOrientation:(UIDeviceOrientation)orientation;
@end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31652 次 |
| 最近记录: |