does anyone know how to delete the words above path in the back button? In this case, how could I delete the word "UNIGO!", in iOS7?
I would leave only the direction indicator, without the written
Rory
Set the title to be a space character before pushing your friend search view controller.
self.title = #" ";
[self.navigationController pushViewController:friendSearchViewControler
animated:YES];
And in -viewWillAppear: set the title to the actual title!
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.title = NSLocalizedString(#"UniGo!", nil);
}
Related
I've made an empty view controller wrapped in a navigation controller, and added a search bar using the navigationItem.searchController. A weird thing though, when tapping the search bar the animation works well but the navigation bar dims down as the entire screen.
This is NOT how it works on Settings and other places, i.e. the color of the navigation bar should stay the same.
Any ideas?
Some code:
- (void)viewDidLoad {
[super viewDidLoad];
UISearchController* searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
searchController.searchResultsUpdater = self;
self.navigationItem.searchController = searchController;
...
}
Simply set dimsBackgroundDuringPresentation or obscuresBackgroundDuringPresentation to NO.
In your viewDidLoad method, add:
self.definesPresentationContext = YES;
I have Two ViewController with Navigation controller,
and i want to press different button to change to next page and Next title also change when i hit a different button?
used this method??
- (void)viewDidLoad {
if Button == A;{
self.title = #"A";
}else Button == B {
self.title = #"B";
}
- (IBAction)A:(id)sender {
self.title =#"A";
}
- (IBAction)B:(id)sender {
self.title =#"B";
}
I know this is a wrong way, cause it just change first page title,but i want to change the second page only,and i just want to description that what i want to do,
please help,
Thanks
Pass your string (Which you want to set on next View Controller) from your first view controller to next view controller and put this self.title = Your passed string in next view controller's viewDidLoad()
my question is simple: how can i change change title of bar button in UIImagePickerController's navigation bar?
I created the controller for UIImagePickerController (triggered by the pressure onto a button) and then tried to modify its properties:
- (IBAction)chooseFromRoll:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeSavedPhotosAlbum]){
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.navigationBar.tintColor = [UIColor colorWithRed:0.42 green:0.18 blue:0.66 alpha:1.0];
//imagePicker.navigationItem.title = #"Scegli foto profilo";
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[imagePicker.navigationController.navigationItem.rightBarButtonItem setTitle:#"Annulla"];
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
but nothing changed, only navigation bar was correctly modified.
Here's the code for function willShowViewController:
- (void) navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
label.textAlignment = 2;
label.frame = CGRectMake(label.frame.origin.x, label.frame.origin.y, label.frame.size.width-200,label.frame.size.height);
label.adjustsFontSizeToFitWidth = YES;
label.font = [UIFont fontWithName:#"Futura" size:15.0];
[label setFont:[UIFont boldSystemFontOfSize:16.0]];
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor whiteColor]];
[label setText:#"Scegli foto profilo"];
[navigationController.navigationBar.topItem setTitleView:label.viewForBaselineLayout];
[navigationController.navigationBar.topItem.rightBarButtonItem setTitle:#"Annulla"];
}
can you tell me where's the mistake?
thanks
Here is a code snippet for twicking the title of the navigation bar in uiimage picker.
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
UINavigationItem *ipcNavBarTopItem;
// add done button to right side of nav bar
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:#"Photos"
style:UIBarButtonItemStylePlain
target:self
action:#selector(saveImages:)];
UINavigationBar *bar = navigationController.navigationBar;
[bar setHidden:NO];
ipcNavBarTopItem = bar.topItem;
ipcNavBarTopItem.title = #"Photos";
ipcNavBarTopItem.rightBarButtonItem = doneButton;
}
Hope this would help you out.
EDIT:
the answer to first question is yes you can use the ibaction or just use the method i provided above to create the button, both should work. if you are using inaction, make sure you declare you controller within it so you can make it appear and dismiss it from within the action method. the answer to the second question if you want to change the title of the view that is presented when image picker from the photo album is presented then you need to create a new subview and pop it up to allow the user to select the desired image then you can change the title the way i did it above. lengthy process, i would not recommend it. the answer to the third question, try using the following code snippet where you declare your button,
[btn.titleLabel setFont:[UIFont boldSystemFontOfSize:13]];
where the btn is the name of your button and you can modify the font name and the size. i hope my answers can help you. good luck and let me know if you need any more help.
I am trying to change the action executed by pressing the backBarButtonItem of a Navigation Controller.
I know that i have to edit the backBarButtonItem before the next view (on which the button with custom behavior should appear) is pushed. So in the previous ViewController i added the following code, to push via segue:
#pragma mark - segue methods
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"SettingsToProfile"]) {
MyProfileViewController* myprofileVC = [segue destinationViewController];
myprofileVC.myProfile = myProfile;
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Settings_" style:UIBarButtonItemStylePlain target:myprofileVC action:#selector(popTOSettingsViewController:)];
} else {
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Settings" style:UIBarButtonItemStylePlain target:nil action:nil];
}
}
The title "Settings_" gets displayed correctly, but "target: myprofileVC action:#selector(popTOSettingsViewController:)" doesn't seem to have any effect at all.
Background:
MyProfileViewController is a View, where the user can edit his/her own information. Whenever the backbarbutton is clicked, i want to check if something in the GUI has been changed by the user. If thats the case, a UIAlterView should ask the user, if he/she wants to save the changing. I tried to work it out with, viewWillDissappear, but the AlterView gets displayed in the next ViewController (and program crashes, if i click on the alterViewButtons).
I'm not sure that you can change the target of a backBarButtonItem. How about self.navigationItem.leftBarButtonItem instead? There's a discussion at self.navigationItem.backBarButtonItem not working ?? Why is the previous menu still showing as the button? that may be relevant.
I have a UINavigationController and UITabBarController visible at the same time. Both the tab bar buttons and the navigation bar take their text from the title of the currently active view.
- (void)viewDidLoad {
[super viewDidLoad];
self.title = #"View Title";
However I want the different. In fact I'd like the navigation controller title to remain the same whichever view is being displayed.
Any ideas?
Many thanks.
Try This
UITabBarItem *tItem = [self tabBarItem];
[tItem setTitle:#"Title for tabbar"];
it won't change your tabbar title when you set the navigation title like
[self setTitle:#"Title for navBar"];
but I found sometimes it changes both tabBar and naviBar
then I insert the TabBar set titling code in -(void)viewWillAppear again to prevent
such happening
Thanks
You'll have to manually assign the title name, as you are doing above, in your other view controllers.
If your view hierarchy is more than two levels deep, be wary as the back button will look a little strange to the user (unless you override it). In fact, if every view has the same title, that may look strange to the user, period...
-(void)viewDidLoad{
[self setTitle:#"Custom Title goes here"];
}
This worked for me.
According to KwangBok Lee, I have tested, the best answer would be:
self.title = #"my settings";//changes both tabbars and navigationbars title
self.tabBarItem.title = #"settings";//only changes tabbars title
What I've found is... using
self.tabBarController.title = #"navTitle";
changes the navigation bar title, while
self.title = #"tabTitle";
changes the tab bar item title.