Navigation bar Navigation Navigation elements, as a result of which the upper area of ​​the buttons on the pushed view controller cannot be unavailable

I have a strong feeling that this may be a bug with Xcode, which Apple is just fixing. I have a view controller built into the navigation controller as the root controller. The view controller has a button that is vertically aligned with the top guide. The view controller button works fine, and the entire area to be displayed works.

enter image description here

However, if I push the same or a similar view controller onto the navigation stack, it will not be fully displayable. The top of the button (about 10 pixels or so) can no longer be displayed. If I try to click in the upper left corner of the button, the "Back" button on the navigation panel will be pressed instead, although I do not explicitly touch the borders of the navigation panel. I suppose this is an apple bug, but I was wondering if anyone knew about the fix. Here is a link to the github project if anyone needs it.

+4
source share
2 answers

iOS. UIView iOS. , UINavigationBar, UITabBar, UISecgmentedControl .. , .

. UINavigationBar :

-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

    if ([self pointInside:point withEvent:event]) {
        self.userInteractionEnabled = YES;
    } else {
        self.userInteractionEnabled = NO;
    }

    return [super hitTest:point withEvent:event];
}

Github.

+5

, - :

class CustomNavBar: UINavigationBar {

  override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
    if pointInside(point, withEvent: event) {
      userInteractionEnabled = true
    } else {
      userInteractionEnabled = false
    }

    return super.hitTest(point, withEvent: event)
  }
}

Swift 3 :

override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
    isUserInteractionEnabled = self.point(inside: point, with: event)
    return super.hitTest(point, with: event)
}
+1

All Articles