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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:36:25+00:00 2026-05-25T06:36:25+00:00

My goal is to have something like a select option in a HTML form,

  • 0

My goal is to have something like a “select” option in a HTML form, but now in my app. After doing research it’s probably best to do this with a table view. I though of the picker view, but the fixed height is too big.

With the interface builder I simply placed a table view on my subclass of UIViewController.

How do I fill the Table view with options? I’ve seen many tutorials, but those are all for having a UITableView as their own class and filling up the entire screen. In my application this is just a small piece of the entire form.

What a nightmare to create a relatively simple thing like a table view. It either crashes or I get a table view that covers my entire view and that is not filled with anything.

The variable countryTable is connected to the object in the interface builder.

Frustrated after a hard day of work. Anyone got the complete working code? That would be great. I already had a great look at apple’s explenation AND various tutorials, but I can’t figure it out.

I’ve tried multiple things, but this is my current code:

@interface myView: UIViewController
{
    NSArray *countryArray;
    IBOutlet UITableView * countryTable;
}
    @property (nonatomic, retain) UITableView *countryTabel;
@end

and in my .m file

@implementation myView
@synthesize countryTable;

- (void)loadView
{
    self.countryTable.dataSource = self;
}

- (void)viewDidLoad
{
NSArray *array = [[NSArray alloc] initWithObjects:@"test1", @"test2",
                  @"test3",nil];
self.countryTable = array;
[array release];   

[super viewDidLoad];
// Do any additional setup after loading the view from its nib.


}

- (void) dealloc
{
    [countryTable release];
    [super dealloc];
}

#pragma mark -
#pragma mark Table View Data Source Methods

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    return [self.countryTable count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
    UITableViewCell *cell = [tableView
                             dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:SimpleTableIdentifier] autorelease];
    }

    NSUInteger row = [indexPath row];
    cell.textLabel.text = [countryTable objectAtIndex:row];
    return cell;

}
@end
  • 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-25T06:36:26+00:00Added an answer on May 25, 2026 at 6:36 am

    You are on the right track. If you were to use a UITableViewController subclass, you would obviously have a full screen table view by default. Going the route of using a UIViewController subclass with a UITableView as a subview in the UIViewController’s view is the right way to go. A few things that you will need to address are:

    1) In the UIViewControllers header file you will need to add <UITableViewDatasource, UITableViewDelegate> as your view controller is responsible for fill implementing this functionally.

    2) In viewDidLoad:, set self.contryTable.delegate = self; and self.countryTable.datasource = self;

    The following protocol methods need to be implemented like so:

    - (NSInteger)tableView:(UITableView *)tableView
     numberOfRowsInSection:(NSInteger)section {
        return countryArray.count; 
    }
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 1;
    }
    
     -(UITableViewCell *)tableView:(UITableView *)tableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
        static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
        if (cell == nil) {
             cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
                                           reuseIdentifier:SimpleTableIdentifier] autorelease];
        }
    
       NSUInteger row = [indexPath row];
       cell.textLabel.text = [countryArray objectAtIndex:row];
    
       return cell;
    

    }

    Hope this helps.

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

Sidebar

Related Questions

I'm probably missing something easy, but I seem to be blocked here... I have
My goal is to have a user select a year and a month. Translate
Using jQuery 1.6.2 HTML that I'm operating on <select id=langId> <option value=0>Argentina - Spanish</option>
I have a simple GridView ; something like this for a regular Item or
The goal is to have a single-threaded event-driven framework. The end-user will do something
I have 2 select statements and would like to combine them so they're displayed
I have a DB like this that I generated from EF: Now I'd like
My end goal is to accomplish something like: CREATE FOREIGN KEY IF NOT EXISTS
I have a query like this: SELECT t1.id, (SELECT COUNT(t2.id) FROM t2 WHERE t2.id
Let's say I have a mySQL table whose structure is like this: mysql> select

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.