【问题标题】:iOS7 UIImagePickerController cancel button disappeariOS7 UIImagePickerController 取消按钮消失
【发布时间】:2013-09-22 07:51:27
【问题描述】:

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

    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 然后在你的子类中 - (void)viewDidLoad,添加一个取消按钮。
  • @Basheer_CAD 谢谢。
  • 您找到解决方案了吗?我也有同样的问题,尝试了很多方法。但是,它仍然无法显示。

标签: uiimagepickercontroller ios7


【解决方案1】:

改UIImagePickerController的navigationBar.tintColor就可以了。

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

【讨论】:

  • 嘿@jxdwinter 有同样的问题,但对于 UIImagePickerControllerSourceTypeCamera。我已经添加了您的代码,但没有用。请帮帮我。
【解决方案2】:

看起来苹果犯了一些错误(iOS 10,Xcode 8),因为无法仅更改 UIImagePickerController 的色调颜色,因为在控制器没有topItem 属性或navigationController 属性之前。在UIImagePickerController extension 中进行了更改。但我在那些被覆盖的方法中检查了navigationControllertopItemviewDidLoadviewWillAppearviewDidAppear。但它仍然是nil。所以我决定在viewWillLayoutSubviews 中查看它,瞧!它不是 nil,所以我们可以在这里设置确切 rightBarButtomItem 的条形颜色!

示例如下:

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

别忘了打电话给super.viewWillLayoutSubviews,这很重要;-) 编辑:但是返回相册屏幕时仍然有问题..

【讨论】:

    【解决方案3】:

    更改 tintColor

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-10
      • 2012-02-01
      • 2019-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-27
      相关资源
      最近更新 更多