Adding a UIBarButtonItem to a programattically allocated UINavigationBar
Posted
by iamdadude
on Stack Overflow
See other posts from Stack Overflow
or by iamdadude
Published on 2010-05-01T14:58:33Z
Indexed on
2010/05/01
15:07 UTC
Read the original article
Hit count: 484
I have a cameraoverlayview that allocates a UINavigationBar to the top of the screen like this -
CGRect navbarFrame = CGRectMake(0, 0, 320, 44);
navigationBar = [[UINavigationBar alloc] initWithFrame:navbarFrame];
navigationBar.delegate = self;
Now I want to add a UIBarButtonItem as the left button to the navigation bar, but the standard navigationbar.leftitem doesn't work. So I tried doing this -
closebutton = [[UIBarButtonItem alloc] initWithTitle:closebuttontext style:UIBarButtonItemStylePlain target:self action:@selector(close)];
navigationBar.topItem.leftBarButtonItem = closebutton;
But it doesn't work either. Can anyone point me in the right direction? As far as the navigation bar loading up correctly in the cameraoverlayview, it works 100%.
© Stack Overflow or respective owner