iOS 7 UIImagePickerController navigationbar overlap

旧城冷巷雨未停 提交于 2019-12-05 18:04:27
user2192708

This works for me:

UIImagePickerController set translucent = NO to navigation Bar

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.navigationController.navigationBar.translucent = NO;

After this, implement this code in your 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;
    }
}

Swift version of the above answer:

func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {
        if navigationController.isKindOfClass(UIImagePickerController.self) {
            viewController.navigationController!.navigationBar.translucent = false
            viewController.edgesForExtendedLayout = .None
        }
    }

As user2192708 mentioned, I think the main issue here is changing the default translucent property of the picker navigationBar and I'm not sure you need to change anything else:

picker.navigationBar.translucent = NO

This will cause the the navigation bar to use the UINavigationBar appearance if you set this somewhere in your app or the "default" if not.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!