Beginning in iOS 7, the rightBarButtonItem in my UINavigationBar gets shifted down after dismissing a modal view controller. The top screen shot shows the correct alignment. The bottom screenshot shows the wrong alignment after dismissing the modal view controller.
- (void) viewDidLoad
{
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@""
style:UIBarButtonItemStyleDone
target:self
action:@selector(didPressRightBarButtonItem)
];
[self.navigationItem.rightBarButtonItem
setImage:[UIImage imageNamed:@"shareLightFlat"]
];
}
- (void) didPressRightBarButtonItem
{
[self.navigationController
presentViewController:[[SomePage alloc] init]
animated:YES
completion:nil];
}
In SomePage, I use this to dismiss itself:
[self dismissViewControllerAnimated:YES completion:nil];
rdelmar :
I have no idea why this is happening, but when I tested this, it worked ok if I changed the title of the button from @\"\" to @\" \". See if that works for you (I got somewhat different results from you -- my button was always misplaced, not only after the presentation and dismissal).",
2013-11-16T01:20:14
Pagly :
you don't need to use initWithTitle: @ \"\"\n\ntry this:\n\nUIBarButtonItem *editBarButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@\"myImage\"] style:UIBarButtonItemStyleDone target:self action:@selector(myAction:)];\n\nself.navigationItem.rightBarButtonItems = @[editBarButton];\n",
2014-06-05T10:49:12