Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Bar or ToolBar trouble in xcode

Ok I was looking at the iPhone iCal app, and was curious whether that top bar is a navigation bar or a toolbar? ive tried using both, but also i cannot figure out how to change the size of the buttons to be as small as the + button in the top right... very confused.. I'm assuming its a navigation bar, but when i read the description of the navigation bar, it said that whenever you are to add a button or item onto the bar, you cannot connect it directly... no idea how else to do it... but anyone wanna help with this issue?

like image 452
trludt Avatar asked Dec 17 '25 14:12

trludt


2 Answers

If you are mentioning about this one It is not UITabBar , it is UINavigationBar, the button on extreme left is inbuilt backbutton of UINavigationBar and the that at right is an extra button that you can add , its clearly shown in this question , and to change the type (ie, + button) you can simply change the button style using

 UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
                                                                    style:UIBarButtonSystemItemAdd target:nil action:nil];

adding button to UINavigationBar

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
    style:UIBarButtonSystemItemAdd target:nil action:nil];
rightButton.width=10;
rightButton.height=10;
    UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Title"];
    item.rightBarButtonItem = rightButton;
    item.hidesBackButton = YES;
    [bar pushNavigationItem:item animated:NO];
    [rightButton release];
    [item release];

But normally you would have a navigation controller, enabling you to write:

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
    style:UIBarButtonSystemItemAdd target:nil action:nil];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];

Hope this helps, regards

like image 188
DD_ Avatar answered Dec 20 '25 07:12

DD_


enter image description here

The top bar with RED circle is UINavigationaBar & the bar with GREEN circle is custom designed. You can the use the below written code to add the system defined Add button to UINavigationaBar

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
                                                                    style:UIBarButtonSystemItemAdd target:nil action:nil];
like image 28
hp iOS Coder Avatar answered Dec 20 '25 09:12

hp iOS Coder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!