Navigation Bar Navigation Items causing top area of buttons on pushed view controller to not be tappable

Scott Kaiser

I have a strong feeling that this might be a bug with Xcode that apple just needs to fix. I have a view controller that is embedded in a navigation controller as the root controller. The view controller has a button that is vertically aligned with the top layout guide. The view controller's button works fine and all of the tappable area is working.

enter image description here

However, if I push the same or a similar view controller on to the navigation stack, it's button will not be completely tappable. The top of the button (about 10 pixels or so) is no longer tappable. If I try to tap at the top left of the button, the back button on the navigation bar is tapped instead, even though I am clearly not tapping the navigation bar bounds. I assume this is a bug with apple but I was wondering if anyone knows of a fix. Here is the link to the github project if anyone needs it.

Warif Akhand Rishi

This is the default behavior for iOS. Many UIViews have this extended touch functionality in iOS. For example, UINavigationBar, UITabBar, UISecgmentedControl etc. I believe this is to make easer touch to these controls.

If you still want to override this default behavior. You can do this by subclassing UINavigationBar and add this method in the subclass:

-(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];
}

A merge request to your Github project is made.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

View on top of navigation bar

From Dev

Show View on the top of navigation bar

From Dev

Show View on the top of navigation bar

From Dev

Add a navigation bar to a view without a navigation controller

From Dev

Add navigation bar on a view controller

From Dev

Embedding Navigation Controller in a Tab Bar Controller changes Safe Area for View Controller

From Dev

How to check if navigation controller is pushed or is a root view controller?

From Dev

How to make navigation bar's sub view pushed with view

From Dev

iOS Navigation Bar Title View Buttons

From Dev

Add navigation bar to a view controller without a navigation controller

From Dev

Add navigation bar to a view controller without a navigation controller

From Dev

Bar Button Items disappear from Navigation Controller

From Dev

Bar Button Items disappear from Navigation Controller

From Dev

Determine if view that appears was pushed or came from back button in navigation bar

From Dev

Can't stop navigation bar covering pushed view - why is it happening?

From Dev

Navigation Bar covers some part of view at Top

From Dev

Navigate from a navigation bar view controller to a tab bar view controller

From Dev

Navigate from a navigation bar view controller to a tab bar view controller

From Java

How to check if a view controller is presented modally or pushed on a navigation stack?

From Dev

ViewController's view's content is not pushed down by navigation controller

From Dev

viewDidAppear() called before view controller is pushed onto navigation stack

From Dev

Moving View Controller to the top of navigation stack iOS

From Dev

Show Navigation Bar in Child View Controller

From Dev

Change Split View Controller Navigation Bar Colour

From Dev

Multiple segues remove navigation bar in view controller

From Dev

IOS Custom View or Navigation Bar Controller

From Dev

How to get the navigation bar on view controller?

From Dev

Changing navigation bar buttons

From Dev

Adding bar button items to nav bar without navigation controller in Swift

Related Related

  1. 1

    View on top of navigation bar

  2. 2

    Show View on the top of navigation bar

  3. 3

    Show View on the top of navigation bar

  4. 4

    Add a navigation bar to a view without a navigation controller

  5. 5

    Add navigation bar on a view controller

  6. 6

    Embedding Navigation Controller in a Tab Bar Controller changes Safe Area for View Controller

  7. 7

    How to check if navigation controller is pushed or is a root view controller?

  8. 8

    How to make navigation bar's sub view pushed with view

  9. 9

    iOS Navigation Bar Title View Buttons

  10. 10

    Add navigation bar to a view controller without a navigation controller

  11. 11

    Add navigation bar to a view controller without a navigation controller

  12. 12

    Bar Button Items disappear from Navigation Controller

  13. 13

    Bar Button Items disappear from Navigation Controller

  14. 14

    Determine if view that appears was pushed or came from back button in navigation bar

  15. 15

    Can't stop navigation bar covering pushed view - why is it happening?

  16. 16

    Navigation Bar covers some part of view at Top

  17. 17

    Navigate from a navigation bar view controller to a tab bar view controller

  18. 18

    Navigate from a navigation bar view controller to a tab bar view controller

  19. 19

    How to check if a view controller is presented modally or pushed on a navigation stack?

  20. 20

    ViewController's view's content is not pushed down by navigation controller

  21. 21

    viewDidAppear() called before view controller is pushed onto navigation stack

  22. 22

    Moving View Controller to the top of navigation stack iOS

  23. 23

    Show Navigation Bar in Child View Controller

  24. 24

    Change Split View Controller Navigation Bar Colour

  25. 25

    Multiple segues remove navigation bar in view controller

  26. 26

    IOS Custom View or Navigation Bar Controller

  27. 27

    How to get the navigation bar on view controller?

  28. 28

    Changing navigation bar buttons

  29. 29

    Adding bar button items to nav bar without navigation controller in Swift

HotTag

Archive