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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:38:40+00:00 2026-05-26T18:38:40+00:00

Bit confused with this one so bear with me… I have a Navigation-based project

  • 0

Bit confused with this one so bear with me…

I have a Navigation-based project which is working fine. I’m trying to create my first custom UIView to make a couple of buttons which I will use in multiple places. One of the buttons needs to push a viewcontroller into the navigation when it’s clicked but I’m not sure how to do this.

When I had the button set up within a view controller I was using:

LocationViewController *controller = [[LocationViewController alloc] initWithNibName:@"LocationViewController" bundle:nil];
        [self.navigationController pushViewController:controller animated:YES];
        [controller release];

but the self.navigation controller won’t work now, will it? How do I access the navigation controller of the viewcontroller that this uiview will be added to?

Hope at least some of that makes sense, as I said it’s my first go at subclassing the uiview and adding it to multiple pages so I’m a bit lost.

EDIT TO ADD – I have the button click events inside the custom UIView, so that is where I’m trying to change the viewcontroller from. Should I instead wire up the events in whichever viewcontroller I add the view to?

  • 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-26T18:38:40+00:00Added an answer on May 26, 2026 at 6:38 pm

    Usually your appDelegate has a UINavigationController property. You can access it in your custom view like this:

    UINavigationController *navController = (MyAppDelegate *)[[[UIApplication sharedApplication] 
             delegate] navigationController];
    

    But more effective way is to make delegate method for your custom view and handle button action in your viewController.

    MyCustomView.h
    
        @protocol MyCustomViewDelegate 
        @interface MyCustomView : UIView  {
            id<MyCustomViewDelegate>    cvDelegate; }
        @property(nonatomic, assign) id<MyCustomViewDelegate>   cvDelegate;
    
        @protocol MyCustomViewDelegate @optional
        -(void)didClickInCustomView:(MyCustomViewDelegate*)view withData:(NSObject*)data; 
        @end
    

    MyCustomView.m

        - (void)myButtonClick:(id)sender 
        { 
            [self.cvDelegate didClickInCustomView:self withData:someData];  
        }
    

    So now you can handle this event in any place where is your custom
    view.

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

Sidebar

Related Questions

Bit confused with this one. Basically, I have a column in a table, and
I am a bit confused about this. If you're building a distributed application, which
I'm a bit confused on this. I have a data table structured like this:
I'm a bit confused as to why this isn't working; I assume that because
I am a bit confused with this: I have a page with a set
I'm a bit confused on how to approach this problem. I have a large
I have been a bit confused on how best to go about this. The
I have searched for this online, but am still a bit confused (as I'm
I am a bit confused why this code compiles. I leave out the necessary
This is a bit confused question for those who don't now advanced SQL... However.

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.