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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:07:36+00:00 2026-05-27T22:07:36+00:00

In my app im using 4 pickerviews in action sheet in which how can

  • 0

In my app im using 4 pickerviews in action sheet in which how can i get the particular value from the particular picker ?
in which i have used a method to get it., but i need a better way to get it., plz help me .,

-(NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
    NSLog(@"pickerView");
    return [pickerArray count];
}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    return [pickerArray objectAtIndex:row];
}

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

    if (validateButton == 0){

        NSInteger temp = (row*5);
        minAsleepInt = temp;
        minAsleepLable.text = [NSString stringWithFormat:@"%d",temp];
    }
    else if(validateButton == 1){

        noOptInt = row+1;
        noOptLable.text = [pickerArray objectAtIndex:row];
    }
    else if(validateButton == 2){

        ageTypeLable.text = [pickerArray objectAtIndex:row];
    }
    else if(validateButton == 3){

        if([pickerArray objectAtIndex:row] == @"Yes"){
            sleepLessBool = YES;
        }else{
            sleepLessBool = NO;
        }
         sleepLessLable.text = [pickerArray objectAtIndex:row];
    }

}


- (IBAction)sleepLessAction:(id)sender {

    validateButton = 3;

    pickerArray = [[NSMutableArray alloc] init];
    [pickerArray addObject:@"Yes"];
    [pickerArray addObject:@"No"];


    actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                                                             delegate:self
                                                    cancelButtonTitle:nil
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:nil];

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

    pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
    pickerView.showsSelectionIndicator = YES;
    pickerView.delegate = self;

    [actionSheet addSubview:pickerView];

    UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
    closeButton.momentary = YES; 
    closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
    closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
    closeButton.tintColor = [UIColor blackColor];
    [closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
    [actionSheet addSubview:closeButton];

    [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

    [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];


}

- (IBAction)ageTypeAction:(id)sender {
     validateButton = 2;

    pickerArray = [[NSMutableArray alloc] init];
    [pickerArray addObject:@"Child"];
    [pickerArray addObject:@"Teen"];
    [pickerArray addObject:@"Adult"];

    actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                                              delegate:nil
                                     cancelButtonTitle:nil
                                destructiveButtonTitle:nil
                                     otherButtonTitles:nil];

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

    pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
    pickerView.showsSelectionIndicator = YES;
    pickerView.delegate = self;

    [actionSheet addSubview:pickerView];


    UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
    closeButton.momentary = YES; 
    closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
    closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
    closeButton.tintColor = [UIColor blackColor];
    [closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
    [actionSheet addSubview:closeButton];

    [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

    [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}

- (IBAction)noOptAction:(id)sender {

     validateButton = 1;
    pickerArray = [[NSMutableArray alloc] init];

    [pickerArray addObject:@"1"];
    [pickerArray addObject:@"2"];
    [pickerArray addObject:@"3"];
    [pickerArray addObject:@"4"];
    [pickerArray addObject:@"5"];
    [pickerArray addObject:@"6"];
    [pickerArray addObject:@"7"];
    [pickerArray addObject:@"8"];    
    [pickerArray addObject:@"9"];

    actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                                              delegate:nil
                                     cancelButtonTitle:nil
                                destructiveButtonTitle:nil
                                     otherButtonTitles:nil];

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

    pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
    pickerView.showsSelectionIndicator = YES;
    pickerView.delegate = self;


    [actionSheet addSubview:pickerView];


    UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
    closeButton.momentary = YES; 
    closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
    closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
    closeButton.tintColor = [UIColor blackColor];
    [closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
    [actionSheet addSubview:closeButton];

    [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

    [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];

}

- (IBAction)minSleepAction:(id)sender {

         validateButton = 0;

    pickerArray = [[NSMutableArray alloc] init];
    [pickerArray addObject:@"0 Minutes"];
    [pickerArray addObject:@"5 Minutes"];
    [pickerArray addObject:@"10 Minutes"];
    [pickerArray addObject:@"15 Minutes"];
    [pickerArray addObject:@"20 Minutes"];
    [pickerArray addObject:@"25 Minutes"];
    [pickerArray addObject:@"30 Minutes"];
    [pickerArray addObject:@"35 Minutes"];
    [pickerArray addObject:@"40 Minutes"];
    [pickerArray addObject:@"45 Minutes"];
    [pickerArray addObject:@"50 Minutes"];
    [pickerArray addObject:@"55 Minutes"];
    [pickerArray addObject:@"60 Minutes"];

    actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                                              delegate:nil
                                     cancelButtonTitle:nil
                                destructiveButtonTitle:nil
                                     otherButtonTitles:nil];

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

    pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
    pickerView.showsSelectionIndicator = YES;
    pickerView.delegate = self;


    [actionSheet addSubview:pickerView];


    UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
    closeButton.momentary = YES; 
    closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
    closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
    closeButton.tintColor = [UIColor blackColor];
    [closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
    [actionSheet addSubview:closeButton];

    [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

    [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}


-(void)dismissActionSheet{
    [actionSheet dismissWithClickedButtonIndex:0 animated:YES];

}

@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-27T22:07:37+00:00Added an answer on May 27, 2026 at 10:07 pm

    you can set a Tag for each picker. And get the particular value from particular picker using the TAG value.

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

Sidebar

Related Questions

I have an app using PHP and the PayPal API. The basic way it
I have an app using a ListView as a main screen. Each row displays
I have an iPhone app using a UINavigationController. On the fourth controller of the
I have an app using SQLite3. It's running pretty well, but I would like
I have an app using the ADO.NET entity framework (the VS2008 version, not the
I have a web app using forms authentication and I have restricted a folder
I have an app using the camera. But each time the app has run
I created an app using the iOS 5 Storyboard feature, and have decided I
I am developing app using facebook API. When I push 'login' button from my
I have a prism app using RIA services, and my authentication service is 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.