tag:blogger.com,1999:blog-6864853053396532264.post4883422816915728532..comments2024-01-25T06:36:43.336-07:00Comments on Osmorphis: Multiple Buttons on a Navigation BarJEShttp://www.blogger.com/profile/05678402081101110580noreply@blogger.comBlogger37125tag:blogger.com,1999:blog-6864853053396532264.post-64773743223173450442012-09-17T07:13:57.928-06:002012-09-17T07:13:57.928-06:00I always tried using "rightBarButtonItems&quo...I always tried using "rightBarButtonItems" and just had problems. Seems using a UIToolbar works. Thanks!Dylanhttp://nullpointerblog.comnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-6401643289449229252012-06-06T15:40:49.958-06:002012-06-06T15:40:49.958-06:00Can therse be added to the titleView? Or centre of...Can therse be added to the titleView? Or centre of the navigation bar? Similar to Facebook iPhone centre buttons on nav bar? Thanks!johndoranhttps://www.blogger.com/profile/16942689580396654046noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-15047113221563099022012-05-23T05:33:46.470-06:002012-05-23T05:33:46.470-06:00Update: You can now do the following to add two bu...Update: You can now do the following to add two buttons on the left:<br /><br /> UIBarButtonItem *refreshBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshPlans:)];<br /> UIBarButtonItem *selectYearBtn = [[UIBarButtonItem alloc] initWithTitle:@"Select Year" style:UIBarButtonSystemItemAction target:self action:@selector(selectYear)];<br /> self.navigationItem.leftBarButtonItems = [[NSArray alloc] initWithObjects: refreshBtn, selectYearBtn, nil];<br /><br />Unfortunately, I haven't seen a way to do this in the Storyboard. Hope this helps.Flaviu Simihaianhttps://www.blogger.com/profile/01202356505879840793noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-51670216493064592042012-05-15T20:10:20.924-06:002012-05-15T20:10:20.924-06:00awesome man, works like a charm!awesome man, works like a charm!xinjunhttps://www.blogger.com/profile/07218530660595079247noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-56473839868496150862012-04-13T01:26:16.861-06:002012-04-13T01:26:16.861-06:00Thank you, V much, But the targets are calling onl...Thank you, V much, But the targets are calling only for one right Barbutton? I cant get the call another methodsBharath.bravemounthttps://www.blogger.com/profile/00769927873958880910noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-73295673549303500692011-11-17T10:04:23.125-07:002011-11-17T10:04:23.125-07:00Thnks a lot!! very helpful!Thnks a lot!! very helpful!Yiyinoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-13331567773897030402011-11-12T13:32:46.585-07:002011-11-12T13:32:46.585-07:00FYI, iOS 5.0 now supports multiple buttons. See t...FYI, iOS 5.0 now supports multiple buttons. See the iOS documentation for UINavigationItem. Specifically, the following:<br /><br />Properties:<br />@property(nonatomic, copy) NSArray *leftBarButtonItems<br />@property(nonatomic, copy) NSArray *rightBarButtonItems<br />@property BOOL leftItemsSupplementBackButton<br /><br /><br />Methods:<br />- (void)setLeftBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated;<br />- (void)setRightBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated;Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-11666715162014138542011-06-27T00:48:36.238-06:002011-06-27T00:48:36.238-06:00Is there any way of alignment of UIBarButtonItem, ...Is there any way of alignment of UIBarButtonItem, We are showing two button add and delete, if there is no items then we are not showing delete button and 'Add' button should be in place of 'Delete' but once 'Delete' button appears 'Add' button should move to left to give the space for 'Delete'. there is only one trick either i need to add one more empty custom button to fill the space and move the 'Add; button to right most but i want other better solution if is there any.Iphonehttps://www.blogger.com/profile/17539683817962680264noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-77059313112633426512011-06-21T23:55:01.262-06:002011-06-21T23:55:01.262-06:00Thanks, this helped me a lot, I made some changes ...Thanks, this helped me a lot, I made some changes to it and documented the code here: http://justabloglol.blogspot.com/2011/06/commentpublic-class-testing-public.htmlAnonymoushttps://www.blogger.com/profile/04854372329122768547noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-84535461849522349932011-06-01T13:17:31.149-06:002011-06-01T13:17:31.149-06:00I found it was easiest to do this trick using a re...I found it was easiest to do this trick using a regular UIView and regular UIButtons inside it (setting the UIView as the argument for initWithCustomView)<br /><br />To make it look right I took a snapshot of the Nav Bar background and used it as my UIView background, and the UIButtons are regular buttons but I used snapshots of a standard button's background when normal and when highlighted as the basis for the buttons. The end result is that it looks perfect while not using any strange coding tricks like setting a height to 44.01.<br /><br />Downside is , if Apple ever decides to change the style of the navigation bar and system buttons, I'll have to update my app with the new graphics.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-46853402842763494462010-12-27T13:02:45.936-07:002010-12-27T13:02:45.936-07:00You are releasing UIImage objects that were not al...You are releasing UIImage objects that were not alloc'd. Remove the two [img release]; statements and see if that helps.JEShttps://www.blogger.com/profile/05678402081101110580noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-88373348339795602462010-12-23T23:45:22.572-07:002010-12-23T23:45:22.572-07:00The custom icons doesn´t work in IOs4.
This is wha...The custom icons doesn´t work in IOs4.<br />This is what i´m doing<br /><br /> <br />// create the container<br /> <br />UIView* container = [[UIView alloc] init];<br /> <br />// create a button and add it to the container<br />UIButton* button = [[UIButton alloc] init];<br /><br />UIImage *img = [UIImage imageNamed:@"close.png"];<br />[button setImage:img forState:UIControlStateNormal];<br />[img release];<br />[container addSubview:button];<br />[button release];<br /> <br />// add another button<br />button = [[UIButton alloc] init];<br />img = [UIImage imageNamed:@"close.png"];<br />[button setImage:img forState:UIControlStateNormal];<br />[img release];<br />[container addSubview:button];<br />[button release];<br /> <br /> <br />// now create a Bar button item<br />UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithCustomView:container];<br /> <br />// set the nav bar's right button item<br />self.navigationItem.rightBarButtonItem = item;<br />[item release];mooschttp://moos.comnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-46251312230306369702010-11-02T22:35:40.594-06:002010-11-02T22:35:40.594-06:00This comment has been removed by the author.Matt Di Pasqualehttps://www.blogger.com/profile/07393376754330599872noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-58368140357631805452010-08-26T23:15:52.470-06:002010-08-26T23:15:52.470-06:00thx guys, useful info.. in my case i am using tint...thx guys, useful info.. in my case i am using tint colors, and buttons were always appearing in blue, even when overriding drawRect, and setting bgColor to clear..<br /><br />my solution was to find the subviews (buttons) of the toolbar and set color on those:<br /><br /> for (UIView *view in [self subviews]) {<br /> [view setTintColor: [self tintColor]];<br /> }stonemonkhttps://www.blogger.com/profile/14543737643591995041noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-66569973299302335832010-08-01T02:54:18.211-06:002010-08-01T02:54:18.211-06:00you are the bestyou are the bestAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-68809912249979594512010-07-09T15:02:22.026-06:002010-07-09T15:02:22.026-06:00While you're at it, I'd also recommend ove...While you're at it, I'd also recommend overwriting another method in your custom UIToolbar class: <br />- (void)setFrame:(CGRect)rect {} <br /><br />This will allow your toolbar to resize when rotated and it will also give you the opportunity to elevate the toolbar by 1 pixel so it directly lines up with the rest of the navigation bar. Below is what I use... depending on how many items you use and how wide they are will depend on your x offset. (I'm using a + button and an edit button.)<br /><br />- (void)setFrame:(CGRect)rect {<br /><br /> if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {<br /> [super setFrame:CGRectMake(216, -1, rect.size.width, 44)];<br /> }<br /> else {<br /> [super setFrame:CGRectMake(381, -1, rect.size.width, 32)];<br /> }<br /><br />}Lucas Stillhttps://www.blogger.com/profile/01680707529483763818noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-91867052248998090872010-07-09T14:27:37.720-06:002010-07-09T14:27:37.720-06:00Petr Fiala's solution can be extended to the o...Petr Fiala's solution can be extended to the other styles as long as you also include:<br /><br />[toolbar setBackgroundColor:[UIColor clearColor]];Lucas Stillhttps://www.blogger.com/profile/01680707529483763818noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-8845543987456860832010-03-24T15:30:05.631-06:002010-03-24T15:30:05.631-06:00Helped me out! - i was stuck exactly with this pro...Helped me out! - i was stuck exactly with this problem, and on an iPad it makes sense to have more than one 'right' item.plain codehttps://www.blogger.com/profile/01095360016400765170noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-64083795327987733902010-03-24T15:28:38.243-06:002010-03-24T15:28:38.243-06:00Great, very helpful!!!Great, very helpful!!!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-58282811632583204512010-03-06T15:30:16.939-07:002010-03-06T15:30:16.939-07:00Yea,
In the code that creates the UIToolbar:
[[UI...Yea,<br />In the code that creates the UIToolbar:<br /><br />[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 133, 44.01)];<br /><br />Set the width (133) to something less.<br /><br />SamShizamhttps://www.blogger.com/profile/16003810299541608823noreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-21139895101027373832010-02-28T19:41:45.281-07:002010-02-28T19:41:45.281-07:00I haven't tried this on the iPhone, but I'...I haven't tried this on the iPhone, but I've used it on the iPad (the toolbar idea). Unfortunately, the rightmost button (if this technique is used on the right side) is too far away horizontally from the edge of the navigation bar. Is there a way to fix this?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-8702021554091834582010-02-12T07:58:50.414-07:002010-02-12T07:58:50.414-07:00Petr Fiala
Your solution sound brilliant. But I ...Petr Fiala <br /><br />Your solution sound brilliant. But I am not getting it right.<br />Can you please elaborate it. You will make my day.<br /><br />Tanks <br />MrTAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-89077964622356924272010-02-04T18:06:26.132-07:002010-02-04T18:06:26.132-07:00Watch out for possible leak in this part of the ab...Watch out for possible leak in this part of the above code:<br />self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];<br /><br />You could use this instead:<br /><br />UIBarButtonItem* rightButtonBar = [[UIBarButtonItem alloc] initWithCustomView:tools];<br />self.navigationItem.rightBarButtonItem = rightButtonBar;<br />[rightButtonBar release];<br />;) ... or use autoreleaseAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-68656679322079961572010-02-02T23:02:18.812-07:002010-02-02T23:02:18.812-07:00I'd also like to thank Petr Fiala - spent hour...I'd also like to thank Petr Fiala - spent hours trying to get transparency on a ToolBar and implemement his solution - worked immediately.<br /><br />Brilliant.Boydleehttp://blog.lemonadestand.com.aunoreply@blogger.comtag:blogger.com,1999:blog-6864853053396532264.post-72623964729231319952010-02-01T05:17:04.669-07:002010-02-01T05:17:04.669-07:00thanx Petr Fiala!!! Works finethanx Petr Fiala!!! Works fineChristanDenkerhttps://www.blogger.com/profile/10125723917608793183noreply@blogger.com