Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:32:00+00:00 2026-05-31T07:32:00+00:00

I have a custom UIButton with UILabel added as subview. Button perform given selector

  • 0

I have a custom UIButton with UILabel added as subview. Button perform given selector only when I touch it about 15points lower of top bound. And when I tap above that area nothing happens.

I found out that it hasn’t caused by wrong creation of button and label, because after I shift the button lower at about 15 px it works correctly.

UPDATE I forgot to say that button located under the UINavigationBar and 1/3 of upper part of the button don’t get touch events.

Image was here

View with 4 buttons is located under the NavigationBar. And when touch the “Basketball” in top, BackButton get touch event, and when touch “Piano” in top, then rightBarButton (if exists) get touch. If not exists, nothing happened.

I didn’t find this documented feature in App docs.

Also I found this topic related to my problem, but there is no answer too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:32:02+00:00Added an answer on May 31, 2026 at 7:32 am

    I found out the answer here(Apple Developer Forum).

    Keith at Apple Developer Technical Support, on 18th May 2010 (iPhone OS 3):

    I recommend that you avoid having touch-sensitive UI in such close proximity to the nav bar or toolbar. These areas are typically known as “slop factors” making it easier for users to perform touch events on buttons without the difficulty of performing precision touches. This is also the case for UIButtons for example.

    But if you want to capture the touch event before the navigation bar or toolbar receives it, you can subclass UIWindow and override:
    -(void)sendEvent:(UIEvent *)event;

    Also I found out,that when I touch the area under the UINavigationBar, the location.y defined as 64,though it was not.
    So I made this:

    CustomWindow.h

    @interface CustomWindow: UIWindow 
    @end
    

    CustomWindow.m

    @implementation CustomWindow
    - (void) sendEvent:(UIEvent *)event
    {       
      BOOL flag = YES;
      switch ([event type])
      {
       case UIEventTypeTouches:
            //[self catchUIEventTypeTouches: event]; perform if you need to do something with event         
            for (UITouch *touch in [event allTouches]) {
              if ([touch phase] == UITouchPhaseBegan) {
                for (int i=0; i<[self.subviews count]; i++) {
                    //GET THE FINGER LOCATION ON THE SCREEN
                    CGPoint location = [touch locationInView:[self.subviews objectAtIndex:i]];
    
                    //REPORT THE TOUCH
                    NSLog(@"[%@] touchesBegan (%i,%i)",  [[self.subviews objectAtIndex:i] class],(NSInteger) location.x, (NSInteger) location.y);
                    if (((NSInteger)location.y) == 64) {
                        flag = NO;
                    }
                 }
               }  
            }
    
            break;      
    
       default:
            break;
      }
      if(!flag) return; //to do nothing
    
        /*IMPORTANT*/[super sendEvent:(UIEvent *)event];/*IMPORTANT*/
    }
    
    @end
    

    In AppDelegate class I use CustomWindow instead of UIWindow.

    Now when I touch area under navigation bar, nothing happens.

    My buttons still don’t get touch events,because I don’t know how to send this event (and change coordinates) to my view with buttons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom UIButton added as subview to a UIView subclass. In my
Basically I have a custom UIButton and this custom button contains subviews. If I
So I have made a custom UIButton and added it to the code and
I have a custom button which inherits from UIButton. I'm handling the TouchUpInside event
I have created a custom UIButton (UIButton subclass) for my application. Within this button's
I have created a custom button called ModuleUIButton which inherits from UIButton . This
I've created a custom button called TaskUIButton that inherits from UIButton. The only difference
I have a custom UIView with nested views of type UIImageView, UILabel and UIButton.
I have a very simply subclass of UIButton that will fire off a custom
I have a custom UITableViewCell which contains several UIButtons. Each button's frame position is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.