开发者

Changing NavigationBar Title of UIImagePickerController

I want to know how we can change the navigation bar title of UIImagePickerController. I tried several ways but couldn't do it.

tried the follwing ways,

imgPicker.title = [NSString stringWithString:@"My Name"];
imgPicker.navigationItem.title = [NSString stringWithString:@"My Name"];

But it still give开发者_Python百科s me the default title called "Photo Albums".Can anyone please tell me how to do it?....

Thanks....


I found the way to do it. When you set your UIImagePickerController delegate to self and implement the following method it worked.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [viewController.navigationItem setTitle:@""];
}

Found it from this link http://forums.macrumors.com/showthread.php?t=533216

Thanks...


This should allow you to set the title (the previous answer had a typo):

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [viewController.navigationItem setTitle:@"Choose A Photo"];
}


Swift

IOS 8 || 9

func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) 
  {
    viewController.navigationItem.title = "video" // Change title
    imagePicker.navigationBar.tintColor = .whiteColor() //Text Color
    imagePicker.navigationBar.titleTextAttributes = [
        NSForegroundColorAttributeName : UIColor.whiteColor()
    ]

  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜