简体   繁体   中英

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.

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:

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

found here: Changing NavigationBar Title of UIImagePickerController

Swift 4

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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