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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:44:13+00:00 2026-05-28T17:44:13+00:00

I have a modal view controller that is presented from my main view, I

  • 0

I have a modal view controller that is presented from my main view, I am adding a “Done” button in the top right hand side of the view (navigationcontroller). However, I can’t get the selector to call the right method. Here is the code I am using to set up the modal view:

    GraphView *graphView = [[[GraphView alloc] initWithNibName:@"GraphView" bundle:nil] autorelease];

//Set values in the graphView view
[graphView setInterest:interestRateSlider.value / 10];
[graphView setMonths: (loanTermSlider.value / 2.0) * 12]; // Years * 12 = months
[graphView setPrincipal:[principal intValue]];

//show the graph view as a modal navigation controller view
UINavigationController *graphNavigationController = [[UINavigationController alloc] initWithRootViewController:graphView];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] 
                               initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
                               target:graphView
                               action:@selector(dismissView:)];
graphView.navigationItem.rightBarButtonItem = doneButton;
[graphNavigationController.navigationItem.rightBarButtonItem setTitle:@"Done"];
[graphView.navigationItem setTitle:@"Graph"];
[self presentModalViewController:graphNavigationController animated:YES];
[graphNavigationController release];
[doneButton release];

Then in my graphView class I have the method:

 -(void) dismissView {
     [self dismissModalViewControllerAnimated: YES];
 }

However, when running the code I get unrecognized selector. The selector is trying to call the method on the UINavigationController variable. How can I get the selector to call the right method?

Thanks

  • 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-28T17:44:14+00:00Added an answer on May 28, 2026 at 5:44 pm

    You made a mistaken when calling the selector:

    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] 
                               initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
                               target:graphView
                               action:@selector(dismissView:)];
    

    when dismissView is defined as

    -(void) dismissView;
    

    you should define dismissView as

    -(void) dismissView:(id)sender;
    

    or call it without colon

    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] 
                               initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
                               target:graphView
                               action:@selector(dismissView)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view controller that I would like to present in a modal
I have a modal view controller whose view comes from a XIB. I want
I have an iPhone app that displays a modal view controller. The modal view
I have a Java project that I'm trying to implement with a model-view-controller design.
I am trying to present a modal view controller. I have read the documentation,
I have a simple project to present a modal view controller and transfer back
I have standard view controller acting as the delegate for a modal view controller
NavigationControllers have ViewController stacks to manage, and limited animation transitions. Adding a view controller
I have a UIViewController (call it NumberTwo) which I presented as a modal view
I have a modal view controller which has only a Webview in it. In

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.