iOS7 UIImagePickerController取消按钮消失

问题描述 投票:1回答:3

取消按钮错过了?!我怎样才能解决这个问题?非常感谢你。

    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
    {
        if(buttonIndex == 1)
        {
            self.ctr = [[UIImagePickerController alloc] init];
            self.ctr.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            self.ctr.delegate = self;
            self.ctr.allowsEditing = YES;
            [self presentModalViewController:self.ctr animated:YES];
        }

    }

uiimagepickercontroller ios7
3个回答
3
投票

只需更改UIImagePickerController navigationBar.tintColor,就可以了。

self.ctr.navigationBar.tintColor = [UIColor redColor];//Cancel button text color
[self.ctr.navigationBar setTitleTextAttributes:@{UITextAttributeTextColor: [UIColor blackColor]}];// title color


0
投票

看起来苹果犯了一些错误(iOS 10,Xcode 8),因为在控制器没有topItem属性或navigationController属性之前,只能改变UIImagePickerController的色调颜色,导致。所以在UIImagePickerController extension做了变化。但我用那些压倒一切的方法检查了navigationControllertopItemviewDidLoadviewWillAppearviewDidAppear。但它仍然是nil。所以我决定在viewWillLayoutSubviews检查它,瞧!它不是零,所以我们可以在这里设置精确rightBarButtomItem的条纹色调!

这是一个例子:

    extension UIImagePickerController {
        open override func viewWillLayoutSubviews() {
            super.viewWillLayoutSubviews()
            self.navigationBar.topItem?.rightBarButtonItem?.tintColor = UIColor.black 
            self.navigationBar.topItem?.rightBarButtonItem?.isEnabled = true
        }
    }

Exampel on simulator (but it tested on )

并且不要忘记打电话给super.viewWillLayoutSubviews,这非常重要;-)编辑:但是当它返回专辑屏幕时仍然有问题..


0
投票

更改tintColor

self.navigationBar.topItem?.rightBarButtonItem?.tintColor = UIColor.black 

如果这不起作用,请通过视图控制器查看是否没有更改导航栏外观并重置更改的位置。

© www.soinside.com 2019 - 2024. All rights reserved.