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 6368479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:40:50+00:00 2026-05-25T00:40:50+00:00

Ive working on an ios app and i am currently trying to add custom

  • 0

Ive working on an ios app and i am currently trying to add custom buttons to my navbar.

UIBarButtonItem *optButton = [[UIBarButtonItem alloc] 
                                       initWithTitle:@"Option1"                                            
                                       style:UIBarButtonItemStyleBordered 
                                       target:self 
                                       action:@selector(Option:)];

        UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:title];
        item.leftBarButtonItem = optButton;

        [navBar pushNavigationItem:item animated:YES];
        [optButton release];
        [item release];



-(void)Option:(id)sender{

    NSLog(@"****Look at me!*****");


}

Now this works in that it displays the button on my navbar on the left as hoped but nothing happens when i click on the button. it doesnt react to touch at all. How do i get the custom button to react to user input? the navbar is created in code and im not using a nav controller or IB at all. I have the navbars delegate set with

[ navBar setDelegate: self ];

within the view controller that owns it. any help would be appreciated

edit: this is how i create the navbar in viewdidload

navBar = [ [ UINavigationBar alloc ] initWithFrame: CGRectMake(0, 0, 320, 45.0f)];
    [ navBar setDelegate: self ];
    [navBar pushNavigationItem:[ [ UINavigationItem alloc ] initWithTitle:@"MoM" ] animated:YES];

    [ self.view addSubview: navBar ];

the reason for not using a nav controller for this is that i want to be able to change properties of the navbar and according to apples references on nav controllers i shouldnt amend the frame of a nav controllers nav bar directly. If im misunderstanding this please say so. I dont need a nav controller in this view controller as it will be displayed at all times in the app. I have separate nav controllers that handle transition of other view controllers separately but this particular view controller is a stand alone entity that is always available at top of the screen no matter what is going on else where

Discussion

It is permissible to modify the barStyle or translucent properties of
the navigation bar but you must never change its frame, bounds, or
alpha values directly. To show or hide the navigation bar, you should
always do so through the navigation controller by changing its
navigationBarHidden property or calling the
setNavigationBarHidden:animated: method.

edit2:

after some more research i see people have had their apps rejected from messing with the navbar frame properties within a nav controller so im def not gonna try this. I see on apples site that they do allow a stand alone navbar which i can mess with its properties and have the view controller take the uinavbar delegate. making the view controller have to handle all the input through the navbar directly. this looks to be the approach i want

If you are using a navigation bar as a standalone object, you should
assign a custom delegate object to the delegate property and use that
object to intercept messages coming from the navigation bar. Delegate
objects must conform to the UINavigationBarDelegate protocol. The
delegate notifications let you track when navigation items are pushed
or popped from the stack. You would use these notifications to update
the rest of your application’s user interface.

  • 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-25T00:40:51+00:00Added an answer on May 25, 2026 at 12:40 am

    Set the current view controller’s navigationItem‘s leftBarButtonItem property instead of creating one and pushing..

    UIBarButtonItem *optButton = [[UIBarButtonItem alloc] 
                                               initWithTitle:@"Option1"                                            
                                               style:UIBarButtonItemStyleBordered 
                                               target:self 
                                               action:@selector(Option:)];
    
    self.navigationItem.leftBarButtonItem = [optButton autorelease];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im working on a Spotify IOS app and i've been trying to get the
I'm currently working in Xcode on an iOS app... I've set up a UIAlertView
I'm currently working in Xcode on an iOS app... I've set up a UIAlertView
I'm working on an iOS app. It currently only works on iOS 4 since
Im working on an ios app and my question is how to change the
I'm working on an iOS app where I use third party libraries. I want
I'm working on an ios app with uitabviewcontroller that plays some music. I don't
I am working on an iOS app that needs to post to either Twitter,
I am currently working on a single page web app optimized for touch devices,
I've been working on getting an image to upload from my iOS app to

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.