So, I have the same problem that many others experience when creating a UIBarButtonItem with UIButton as a custom view.
Basically a button is about 10 pixels, far away either to the left or to the right. When I use a regular BarButtonItem without a custom view, this does not happen.
This post provided a partial solution: UIBarButton with custom view
Here is my code that I created by subclassing UIButton (as indicated in another post)
- (UIEdgeInsets)alignmentRectInsets { UIEdgeInsets insets; if ([self isLeftButton]) { insets = UIEdgeInsetsMake(0, 9.0f, 0, 0); } else { // IF ITS A RIGHT BUTTON insets = UIEdgeInsetsMake(0, 0, 0, 9.0f); } return insets; } - (BOOL)isLeftButton { return self.frame.origin.x < (self.superview.frame.size.width / 2); }
This works fine, but when I exit the navigation controller from the navigation controller back to this main view, the button is still incorrectly positioned for about 0.3 seconds, and then it is inserted into the desired insert.
This is a HUGE eyeball, and I have no idea how to stop it from clicking. Any suggestions? Thank!
ios7 uibutton uinavigationcontroller uibarbuttonitem
Kyle Begeman 07 Oct '13 at 19:59 2013-10-07 19:59
source share