我在 iOS7 中访问照片库时遇到问题(iOS6 正常)。导航栏似乎与相册 View 重叠,我尝试设置 picker.edgesForExtendedLayout = UIRectEdgeNone;
但它不起作用。
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
picker.edgesForExtendedLayout = UIRectEdgeNone;
}
[self presentViewController:picker animated:YES completion:nil];
看我截图
最佳答案
这对我有用:
UIImagePickerController 设置半透明 = NO 到导航栏
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.navigationController.navigationBar.translucent = NO;
在此之后,在您的 UIImagePickerController 委托(delegate)中实现此代码:
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if ([navigationController isKindOfClass:[UIImagePickerController class]])
{
viewController.navigationController.navigationBar.translucent = NO;
viewController.edgesForExtendedLayout = UIRectEdgeNone;
}
}
关于iOS 7 UIImagePickerController 导航栏重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20783321/