These are my top iOS bloopers for this week (and corresponding fixes):
- For proper spacing of Toolbar Items in iOS you can use
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
//this will center-align myButton
[self setToolbarItems:[NSArray arrayWithObjects: flexibleSpace, myButton, flexibleSpace, nil]];
or you can also use
UIBarButtonSystemItemFixedSpace system item and set the width. - 2nd or Bottom Navigation Toolbar in a popover (UIPopoverController)
It is actually the toolbar item of the navigation controller.
Assuming you added a navigation controller in a popover for the title,
using initWithContentViewController: [UINavigationController]
To show bottom toolbar, just set the navigation controller's toolbarHidden to NO.
- When changing the width of a UIBarButton, I often try to find the frame, but it's not there. Apparently, just set it directly using setWidth method.
- Change Navigation Controller's Back Button Title or Text
Just accessing the backBarButtonItem will not work, you have to set the button entirely.
self.navigationItem.backBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Back"
style: UIBarButtonItemStyleBordered
target:nil
action:nil] autorelease]; - UIButton is not showing , also related topic: UIBarButtonItem not showing UIButton custom view
[btn setBackgroundImage:image forState:UIControlStateNormal]
instead of
btn.imageView.image = .. //ugh
The same way if title is not showing, use:
[btn setTitle:itemTitle forState:UIControlStateNormal];
instead of
btn.titleLabel.text = ..
No comments:
Post a Comment