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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:45:38+00:00 2026-05-27T13:45:38+00:00

I want to do an sample application where in a view i have two

  • 0

I want to do an sample application where in a view i have two buttons one is COUNTRY and another is STATE.
when i click on a country button the country list should appear in a tableview class like a popup and when i click on state button state list should appear in a tableview like popup,So how can i do this please suggest with sample code.

NOTE:I should use only one TableViewcontroller class for both country and state Data list.

  • 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-27T13:45:39+00:00Added an answer on May 27, 2026 at 1:45 pm

    Here is the Code:

    RootViewController.h

    @interface RootViewController : UIViewController {
    
    UIButton *btnCountry;
    UIButton *btnState;
    
    NSMutableArray *tempArray;
    NSMutableArray *countryArray;
    NSMutableArray *stateArray;
    
    IBOutlet UITableView *tempTable;
    }
    
     @property (nonatomic,retain) UIButton *btnCountry;
     @property (nonatomic,retain) UIButton *btnState;
     @property (nonatomic,retain) NSMutableArray *countryArray;
     @property (nonatomic,retain) NSMutableArray *stateArray;
    @property (nonatomic,retain) NSMutableArray *tempArray;
    @property (nonatomic,retain) UITableView *tempTable;
    
    
    - (IBAction) showState:(id)sender;
    - (IBAction) showCountry:(id)sender;
    

    @end

    RootViewController.m

    @implementation RootViewController
    
    @synthesize btnState,btnCountry, stateArray,countryArray,tempArray;
    @synthesize tempTable;
    
    #pragma mark -
    #pragma mark View lifecycle
    
    
    - (void)viewDidLoad {
    
    [super viewDidLoad];
    
    tempTable.hidden = YES;
    
    countryArray = [[NSMutableArray alloc]initWithObjects:@"India",@"Pakistan",@"USA",nil];
    stateArray = [[NSMutableArray alloc]initWithObjects:@"Gujarat",@"Maharashtra", @"Karnataka",nil];
    tempArray = [[NSMutableArray alloc]init];
    
    }
    
    
    
    - (IBAction) showCountry:(id)sender
    {
    btnCountry = (UIButton *)sender;
    tempArray = countryArray;
    [tempTable reloadData];
    if([btnCountry isSelected])
    {
        tempTable.hidden = YES;
        btnCountry.selected = NO;
    }
    else
    {
        tempTable.hidden = NO;
        btnCountry.selected = YES;
    }
    }
    
    
    - (IBAction) showState:(id)sender
    {
    btnState = (UIButton *)sender;
    tempArray = stateArray;
    [tempTable reloadData];
    
    if([btnState isSelected])
    {
        tempTable.hidden = YES;
        btnState.selected = NO;
    }
    else
    {
        tempTable.hidden = NO;
        btnState.selected = YES;
    }
    }
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
    }
    
    
    // Customize the number of rows in the table view.
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section      {
    
    return [tempArray count];
     }
    
    
    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    cell.textLabel.text = [tempArray objectAtIndex:indexPath.row];
    
    return cell;
    }
    
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application based on CoreDataBooks. I want to toggle two images in
I have one application in which list of videos that are coming through xml
In my application i have two images original upper image and down reflection one.
Hai Friends, I have created an sample application, in which i have a list
i have a simple chat application in flex 3 and i want to make
I have a really simple blog application and I want to add a really
I have a simple quiz application and I want display a nice timer /
I developed one simple android application targeting the Mobiles with android 2.0 OS.I want
I have a fairly simple iPhone application that I want to have run on
I have created sample application that insert 12 rows in tableview.And inserted fine.When after

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.