我通過UIPopOver顯示UIImagePicker(本身在UIView)。這工作正常,但是當iPad旋轉到右側時,我會在彈出窗口的左側獲得一個奇怪的黑色條,如下圖所示。取消按鈕也部分偏離屏幕的右側。這在任何其他奇怪的方向中都不會發生。在iPad的UIImagePicker黑色酒吧 - 只在風景右方
該代碼也在下面列出。任何人都可以提出爲什麼我得到這個黑色的酒吧?
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
CGFloat width = CGRectGetWidth(self.view.bounds);
CGFloat height = CGRectGetHeight(self.view.bounds);
UIViewController *containerController = [[UIViewController alloc] init];
containerController.contentSizeForViewInPopover = CGSizeMake(width, height);
[imagePickerController.view setFrame:containerController.view.frame];
[containerController.view addSubview:imagePickerController.view];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
Class cls = NSClassFromString(@"UIPopoverController");
if (cls != nil) {
popoverController = [[UIPopoverController alloc] initWithContentViewController:containerController];
[popoverController presentPopoverFromRect:selectedRect inView:self.view permittedArrowDirections:4 animated:YES];
[containerController release];
}
非常感謝這個答案。 – portoalet