简体   繁体   English

如何在UIImagePicker中更改导航栏标题?

[英]How to change navigation bar title in UIImagePicker?

I'm writing in Swift, so there isn't enough info that I can find to address this. 我正在用Swift写作,所以没有足够的信息可以解决这个问题。

Anyway, I have everything working fine, ie: photo library selection view presented, editing works fine and cropped image gets exported to an image view. 无论如何,我的所有工作都很好,即:提供了照片库选择视图,编辑工作正常,并且将裁剪后的图像导出到了图像视图。

My problem is really when the view is presented modally, the title says "Photos". 我的问题是,以模态显示视图时,标题实际上是“照片”。 How do I change this to something else? 如何将其更改为其他内容?

var imagePicker = UIImagePickerController()
imagePicker.navigationItem.title = "MY TITLE"

Changing the title text attributes work, but not changing the title itself. 更改标题文本属性有效,但不能更改标题本身。

make yourself the delegate of imagePicker and implement: 使自己成为imagePicker的委托并实现:

func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {
    viewController.navigationItem.title = "asdf"
}

found here: Changing NavigationBar Title of UIImagePickerController 在这里找到: 更改UIImagePickerController的NavigationBar标题

Swift 4 斯威夫特4

func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
                viewController.navigationItem.title = "asdf"
      }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM