3 回答

TA貢獻1785條經驗 獲得超8個贊
拍攝后我不想旋轉圖像;我想讓預覽在橫向模式下正確顯示。因此,在iOS 6中,我允許在應用程序級別使用縱向模式,但是將應用程序的根視圖控制器設置為class MyNonrotatingNavigationController,其定義如下:
@implementation MyNonrotatingNavigationController
-(NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
@end
因此,此導航控制器內顯示的所有內容都將沿橫向顯示(您可以使用任何視圖控制器來執行此操作)。現在,當我需要顯示圖像選擇器時,我用支持縱向模式的通用控制器替換了應用程序窗口的根視圖控制器。為了防止老根視圖控制器,并從取消分配自己的觀點,我保持指向他們,直到我準備把它們放回應用程序窗口。
#define APP_DELEGATE ((MyAppDelegate*)[[UIApplication sharedApplication] delegate])
static UIViewController *pickerContainer = nil;
static UIViewController *oldRoot = nil;
static UIView *holdView = nil;
-(void) showPicker
{
...create UIImagePickerController...
oldRoot = APP_DELEGATE.window.rootViewController;
holdView = [[UIView alloc] initWithFrame:APP_DELEGATE.window.bounds];
[holdView addSubview:oldRoot.view];
pickerContainer = [UIViewController new];
pickerContainer.view = [[UIView alloc] initWithFrame:APP_DELEGATE.window.bounds];
APP_DELEGATE.window.rootViewController = pickerContainer;
[pickerContainer presentViewController:picker animated:YES completion:NULL];
}
-(void) imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
[pickerContainer dismissViewControllerAnimated:YES completion:^{
dispatch_async( dispatch_get_main_queue(), ^{
APP_DELEGATE.window.rootViewController = oldRoot;
[APP_DELEGATE.window addSubview:oldRoot.view];
pickerContainer = nil;
oldRoot = nil;
holdView = nil;
});
}];
}
有點痛苦,但它確實適用于照片和視頻。圖像選擇器的控件以縱向模式顯示,但應用程序的其余部分僅橫向顯示。

TA貢獻1790條經驗 獲得超9個贊
我通過使UIImagePickerController
屏幕以全屏模式顯示來解決了此問題,這也是Apple建議在iPad上使用的模式。
從UIImagePickerController
文檔:
在iPad上,如果您指定UIImagePickerControllerSourceTypeCamera的源類型,則可以模式(全屏)或使用彈出窗口來呈現圖像選擇器。但是,Apple建議您僅全屏顯示相機界面。
- 3 回答
- 0 關注
- 696 瀏覽
添加回答
舉報