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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:42:23+00:00 2026-06-09T03:42:23+00:00

In my app, when button is pressed, I am launching UIActionSheet with UIPickerView and

  • 0

In my app, when button is pressed, I am launching UIActionSheet with UIPickerView and UIToolBar in it. Its working perfectly by using the following code. I am trying to get the picker value and set that value to the called button, but I couldn’t find the exact solution for it.

- (IBAction)showPicker:(id)sender {

 actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                                                         delegate:self
                                                cancelButtonTitle:nil
                                           destructiveButtonTitle:nil
                                                otherButtonTitles:nil];//as we want to display a subview we won't be using the default buttons but rather we're need to create a toolbar to display the buttons on 

[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

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

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

[actionSheet addSubview:pickerView];
//[pickerView release];     

pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerToolbar sizeToFit];

NSMutableArray *barItems = [[NSMutableArray alloc] init];   

UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];  
[barItems addObject:flexSpace];  

UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)];  
[barItems addObject:doneBtn];  

UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)];  
[barItems addObject:cancelBtn];  


[pickerToolbar setItems:barItems animated:YES];  

[actionSheet addSubview:pickerToolbar];  

[actionSheet addSubview:pickerView];  

[actionSheet showInView:self.view];  

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

}

When Done button in Tool bar pressed it will call this method

-(void)doneButtonPressed:(id)sender{  
//Do something here here with the value selected using [pickerView date] to get that value   
[actionSheet dismissWithClickedButtonIndex:1 animated:YES];   
[pickerView release];
[pickerToolbar release];
[actionSheet release];     
}  

Here is my questions

How to get The picker value from action sheet?

How to set that value to the button?

Thanks for your help guys

  • 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-06-09T03:42:25+00:00Added an answer on June 9, 2026 at 3:42 am

    Assuming the pickerView datasource has only one component you can get the selected row using:

    NSInteger row = [pickerView selectedRowInComponent:0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app offers a share/tell-a-friend function. When the share button is pressed the following
i am working on my App. in between i pressed the Home button on
In my app I want a button which when pressed copies a file stored
I need to force quit my app when I pressed the Answer button in
Here's what currently happens in my app: Locking: iPhone Lock Button Pressed -> Audio
In my app I have a requirement that if the Home button is pressed
Currently, my app loads a UIImagePickerController when a button is pressed. I would like
I want to start an email app from app on button pressed. But when
My app contained download button and whenever that button is pressed, I want some
I create the app with button Sending. When I pressed this button, the app

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.