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

  • Home
  • SEARCH
  • 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 1062175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:35:01+00:00 2026-05-16T18:35:01+00:00

Ive got an iPhone/iPad universal application and I wanted to have a custom navigation

  • 0

Ive got an iPhone/iPad universal application and I wanted to have a custom navigation bar where the top half of the nav bar contained our companies logos, and the bottom half was the standard navigation bar.

I figured out how to do this, showing in the code below, but my UIButton “logosButton” doesnt always respond to being clicked, it appears as though only certain parts of the button are active, and others dont do anything at all… I cannot figure out why this is.

- (void)viewDidLoad {
    [super viewDidLoad];
    [[self view] addSubview: navController.view];

    float width = IS_IPAD ? 768.0f : 320.0f;
    float logosHeight = IS_IPAD ? 20.0f : 20.0f;
    float barHeight = IS_IPAD ? 32.0f : 32.0f;

    self.navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, logosHeight, width, barHeight)];

    UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, logosHeight)];
    UIButton *logosButton = [[UIButton alloc] init];
    [logosButton setBackgroundImage:[UIImage imageNamed:@"logo_bar_alone.png"] forState:UIControlStateNormal];
    [logosButton setBackgroundImage:[UIImage imageNamed:@"logo_bar_alone.png"] forState:UIControlStateHighlighted];

    [logosButton addTarget:self action:@selector(logosButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [logosButton setFrame: CGRectMake(0, 0, width, logosHeight)];
    [tempView addSubview: logosButton];
    [[self view] addSubview: tempView];
    [tempView release];

    [[self view] addSubview: self.navBar];

    self.navItem = [[UINavigationItem alloc] initWithTitle: @"Home"];
    [self.navBar pushNavigationItem:self.navItem animated:NO];
}

The method: logosButtonClicked does get fired every now and then when I click on the UIButton, but I clearly am clicking on certain spots where nothing happens at all…

Very frustrating, I dont seem, to see a pattern in regards to where its active, but could someone please help out here?

EDIT

I think I have just stumbled across something, I changed the button to a UIButtonTypeRoundedRect and got rid of the images (and also made it larger) and it appears that I cannot click on the bottom OR top sections of the button where the button is rounded. So the middle rectangular section is the only section where I can click… why would this be?

EDIT 2
For anyone reviewing this question, please see taber’s latest edit on his answer. The Navigation Controller is eating touches for some reason, and I need to figure out why this is so, could be a bug?

  • 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-16T18:35:01+00:00Added an answer on May 16, 2026 at 6:35 pm

    FINAL ANSWER 🙂

    Okay after reviewing the project it looks like the UINavigationController that is positioned below the button is eating touches globally. Which is definitely weird because it was added as a subview BELOW your button. So there must be some kind of funky frame/touch-eating going on with the UINavigationController. I tried to set navigationController.titleView.userInteractionEnabled = NO but to no avail. If anyone knows how to basically make UINavigationController and UINavigationBar not eat touches (I’m talking about the background where no buttons exist) then please chime in. The UIButton touches work just fine when the UINavigationController isn’t added to the view.

     

    Original Answer

    It may be some other UI elements in [self view] or tempView sitting on top of the button and intercepting taps. You might want to try either commenting out everything else in the view(s) and/or try setting the userInteractionEnabled property on them like this:

    [otherUIElement setUserInteractionEnabled: NO];

    EDIT:
    This code makes it so that you CAN click the round rect edges but NOT the title text. So I suspect that it’s some sort of subview preventing the button from catching the tap.

    
    [logosButton addTarget:self action:@selector(logosButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [logosButton setFrame: CGRectMake(0, 0, 320.0, 50.0)];
    [logosButton setTitle: @"HELLO" forState: UIControlStateNormal];
    [logosButton.titleLabel setUserInteractionEnabled: YES];
    

    EDIT #2:

    Try using this subclassed button and see if the issue still occurs:

    
    // NavBtn.h
    
    @interface NavBtn : UIButton {
    
    }
    
    -(id)initWithTitle:(NSString *)text;
    
    @end
    
    
    // NavBtn.m
    
    #import "NavBtn.h"
    
    @implementation NavBtn
    
    - (id)initWithTitle:(NSString *)text {
      if ((self = [super initWithFrame: CGRectMake(0, 0, 320, 50)])) {
        [self setTitle: text forState: UIControlStateNormal];
        self.backgroundColor = [UIColor clearColor];
        self.opaque = NO;
        [self setBackgroundImage:[UIImage imageNamed:@"logo_bar_alone.png"] forState: UIControlStateNormal];
        [self setBackgroundImage:[UIImage imageNamed:@"logo_bar_alone.png"] forState: UIControlStateHighlighted];
      }
      return self;
    }
    
    // i guess you shouldn't need to mess with layoutSubviews 
    
    @end
    

    To load it into your view:

    
    #import "NavBtn.h"
    
    ... in viewDidLoad, etc ...
    NavBtn *btn = [[NavBtn alloc] initWithTitle: @"hey"];
    [self.view addSubview: btn];
    [btn release];
    
    

    If THAT doesn’t work, there’s got to be some kind of third party library doing some funky category overriding of your UIButton class or something.

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

Sidebar

Related Questions

I'm working on an iPhone/iPad application and I've got an unpleasant issue. There is
I've got a universal ipad/iphone app that allows the user to watch a video,
On an iPhone App, I've got a custom keyboard which works like the standard
I'm uploading photos to Facebook from my iPhone application. I've got it working, except
I've got an iPhone app and an iPad app, both running the same web
I just updated our app to an universal app for iPhone and iPad. I
I have this simple json file in my iphone/ipad project. {initial_page : Page_Selected} Page_Selected
I've made an application on Flurry for iPhone. I wanted to use the same
I've got a Navigation iPhone app and it's second level controller is currently a
I've got an issue similar to this one: iPad/iPhone browser crashing when loading images

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.