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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:52:59+00:00 2026-05-14T01:52:59+00:00

I need to pop up a quick dialog for the user to select one

  • 0

I need to pop up a quick dialog for the user to select one option in a UITableView from a list of roughly 2-5 items. Dialog will be modal and only take up about 1/2 of screen. I go back and forth between how to handle this. Should I subclass UIView and make it a UITableViewDelegate & DataSource?

I’d also prefer to lay out this view in IB. So to display I’d do something like this from my view controller (assume I have a property in my view controller for DialogView *myDialog;)

NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"DialogView" owner:myDialog options:nil];
myDialog = [nibViews objectAtIndex:0];
[self.view addSubview:myDialog];

problem is i’m trying to pass owner:myDialog which is nil as it hasn’t been instantiated…i could pass owner:self but that would make my view controller the File's Owner and that’s not how that dialog view is wired in IB.

So that leads me to think this dialog wants to be another full blown UIViewController… But, from all I’ve read you should only have ONE UIViewController per screen so this confuses me because I could benefit from viewDidLoad, etc. that come along with view controllers…

Can someone please straighten this out for me?

  • 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-14T01:52:59+00:00Added an answer on May 14, 2026 at 1:52 am

    There is no such thing as a view controller being on the screen; its view is on the screen. With that said, you can present as many views as you want on the screen at once.

    I would create a new view and view controller. You would not make a UIView be a UITableViewDelegate, you make a UIViewController be a UITableViewDelegate. But instead of doing that manually, instead make your new view controller a subclass of UITableViewController, if you’re using iPhone OS 3.x+. You can then present this view controller modally.

    You probably want to give the user a chance to cancel out of the selection. A good way to do that is to wrap your new dialog view controller in a UINavigationController and then put a “Cancel” button in the nav bar. Then use the delegate pattern to inform the parent view controller that the user has made their choice so you can pop the stack.

    Here’s what the code will look like inside your parent view controller, when you want to present this option dialog:

    - (void)showOptionView
    {
        OptionViewController* optionViewController = [[OptionViewController alloc] initWithNibName:@"OptionView" bundle:nil];
        optionViewController.delegate = self;
        UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:optionViewController];
        [self.navigationController presentModalViewController:navController animated:YES];
        [navController release];
        [optionViewController release];
    }
    

    Your OptionViewController .h will look like this:

    @protocol OptionViewControllerDelegate;
    
    @interface OptionViewController : UITableViewController
    {
        id<OptionViewControllerDelegate> delegate;
    }
    
    @property (nonatomic, assign) id<OptionViewControllerDelegate> delegate;
    
    @end
    
    @protocol OptionViewControllerDelegate <NSObject>
    - (void)OptionViewController:(OptionViewController*)OptionViewController didFinishWithSelection:(NSString*)selection;
    // or maybe
    - (void)OptionViewController:(OptionViewController*)OptionViewController didFinishWithSelection:(NSUInteger)selection;
    // etc.
    @end
    

    Your OptionViewController.m will have something like this:

    - (void)madeSelection:(NSUInteger)selection
    {
        [delegate OptionViewController:self didFinishWithSelection:selection];
    }
    

    Which has a matching method back in your original view controller like:

    - (void)OptionViewController:(OptionViewController*)OptionViewController didFinishWithSelection:(NSUInteger)selection
    {
        // Do something with selection here
    
        [self.navigationController dismissModalViewControllerAnimated:YES];
    }
    

    There are plenty of examples throughout Apple’s sample source code that follow this general pattern.

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

Sidebar

Related Questions

Quick question: When I'm in Google Reader, it will flash and pop up a
I'm retrieving raw text (includes header, and message) from a POP server. I need
I need to make a pop-up window for users to log-in to my website
Need a way to allow sorting except for last item with in a list.
My current code is pretty quick, but I need to make it even faster
I need a way to close the browser (not a pop up) using Javascript.
I am new to Android Programming. I need to display a Pop-Up message in
I now need to design a chemistry periodic table. I will have a set
Need a function that takes a character as a parameter and returns true if
Need to an expression that returns only things with an I followed by either

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.