I found out the hard way UIBarButtonItem frame width is 0. After googling, i found a method to traverse the nav controllers subviews to find the left bar button’s width. It works but it just seems like there has to be a cleaner way to do this.
There would be no reason my app would get rejected for using this method right?
UIView *leftBarButtonView = nil;
for (UIView* v in self.navigationController.navigationBar.subviews) {
if ([[v class].description isEqualToString:@"UINavigationButton"]) {
if (leftBarButtonView==nil) {
if (v.frame.origin.x > 0.0)
leftBarButtonView = v;
} else if (v.frame.origin.x < leftBarButtonView.frame.origin.x && v.frame.origin.x>0.0) {
leftBarButtonView = v; // this view is further right
}
}
}
No, it won’t probably get rejected – probably, as nobody except Apple can say it for sure. However, one thing is sure:
won’t work. Use
instead.