iOS 7 UIImagePickerController 导航栏重叠

标签 ios ios7 uiimagepickercontroller

我在 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];

看我截图

enter image description here

最佳答案

这对我有用:

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/

相关文章:

ios - 将函数结果返回到输出参数

iOS 原生 map URL 方案多个引脚

ios - 在 Controller 之间传递难度级别

ios - 使用 swift 和 parse 保持当前用户登录

objective-c - 如何在 iPad 上更改 UIImagePickerController 的大小宽度?

uiimagepickercontroller - 如何在 swift 中使用 UIImagePickerController 捕获相机?

ios - 使用 Swift 用 Core Data 对象填充 UIPickerView

ios - 如何将数据从父 View Controller 传递到子容器 View Controller

IOS 7 UITextField resignFirstResponder 坏

objective-c - 在UIStoryboardPopoverSegue中调用ImagePickerController会导致presentViewController崩溃