Reputation: 1721
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 gives me the default title called "Photo Albums".Can anyone please tell me how to do it?....
Thanks....
Upvotes: 6
Views: 10020
Reputation: 5299
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()
]
}
Upvotes: 3
Reputation: 1721
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...
Upvotes: 49
Reputation: 121
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"];
}
Upvotes: 4