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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:39:23+00:00 2026-05-13T01:39:23+00:00

I am trying to place a Dismiss or Done button in the top right

  • 0

I am trying to place a “Dismiss” or “Done” button in the top right corner in a navigation control for a ModalView that closes the view. Using a normal UIView, I am able to do this. However, when I try to use a UITableView for my ModalView, I am no longer able to set the BarButton’s target to a parent controller.

The “dismissModalController” method is in a separate controller than the TableView’s, but the button wants to default to the TableViewController rather than using a target Controller where “dimissModalController” is.

How can I replicate the functionality of the button in UIView with that of the UITableView?

UITableView Initiation (Not Working):

   -initWithStyle:(UITableViewStyle) style {
        ToolbarController *myParent;
 if(self=[super initWithStyle:style]) {
  self.title=@"Widgets List";
  UIBarButtonItem *rightButton = 
  [[UIBarButtonItem alloc] initWithTitle:@"Dismiss" 
           style:UIBarButtonItemStyleDone
          target:myParent
          action:@selector(dismissModalController)
   ];
  self.navigationItem.rightBarButtonItem=rightButton;
  [rightButton release];
 }
 return self;}

UIView Initiation (Works):

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
    parent:(ToolbarController*) myParent{
 if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
  UIBarButtonItem *rightButton = 
  [[UIBarButtonItem alloc] initWithTitle:@"Dismiss" 
           style:UIBarButtonItemStyleDone
          target:myParent 
          action:@selector(dismissModalController)
   ];
  self.navigationItem.rightBarButtonItem=rightButton; 
  [rightButton release];

 }
 return self;
}
  • 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-13T01:39:23+00:00Added an answer on May 13, 2026 at 1:39 am

    Tried something that works but throws a warning. However, the warning never ends the program. Basically I set parent in the parameter and pass a ToolbarController when I call this method. A hybrid between the two other attempts. I didn’t think it would work and it’s probably bad practice, but it does fix the problem.

    -initWithStyle:(UITableViewStyle) style parent:(ToolbarController*) myParent {
            self.title=@"Widgets List";
            UIBarButtonItem *rightButton = 
            [[UIBarButtonItem alloc] initWithTitle:@"Dismiss" 
                                             style:UIBarButtonItemStyleDone
                                            target:myParent
                                            action:@selector(dismissModelController)
             ];
            self.navigationItem.rightBarButtonItem=rightButton;
            [rightButton release];
        return self;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to place a nice border around an image that's 250x250, using only
I'm currently trying to place a progress bar on the top left corner of
I'm trying to place a banner at the top of a listview, one that
I'm trying to place a button. I have its position set to absolute, so
I was trying to place some simple effects on an image using HBox using
I am trying to place an ad grid for my panorama view. The problem
I am trying to place a search text box on the right hand side
I am trying to place a circlular div (border-radius:85) on top of a <li><a></a></li>
I`m trying to place all form fields (and the submit button) on a single
I'm trying to place multiple markers on a map that are provided from an

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.