Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIToolbar items disappear - Weird bug in ios6

This is the current setup.

I have the navigationController's toolbar with 5 buttons, and tapping on them hides the toolbar for 2 seconds, and then shows the toolbar again (except the 5th button - which brings up an actionsheet with buttons (ACTION & CANCEL)).

On tapping on the 1-4 buttons, I do a self.navigationController.toolbarHidden = YES; and after exactly 2 seconds, I set the self.navigationController.toolbarHidden = NO; and this brings back the toolbar, and everything's fine.

On tapping the 5th button, which brings up action sheet.

  1. If i tap on CANCEL actionsheet => actionSheet dismissed => Toolbar is fine.
  2. If I tap on ACTION button I do a self.navigationController.toolbarHidden = YES; and after 2 seconds... self.navigationController.toolbarHidden = NO; but now... The toolbar buttons are GONE.

Further investigating...

I can see the the toolbarButtons seem to have their alpha values set to 0.

I have no idea why the toolbar items' alpha are set to value = 0 after actionsheet operation.

Can anyone tell me the root cause for this?

like image 388
Legolas Avatar asked Dec 08 '25 21:12

Legolas


1 Answers

Have you tried setting the toolbar items array to nil? I had this same problem and it turned out that putting a check around when you set the toolbar's items seemed to work:

if ([self.navigationController.toolbar.items count] > 0) {
   [self.navigationController.toolbar setItems:nil];
}

[self.navigationController.toolbar setItems:toolbarItems]; //toolbarItems is your array of UIBarButtonItems.
like image 87
Hector Matos Avatar answered Dec 10 '25 12:12

Hector Matos



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!