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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:06:13+00:00 2026-06-11T02:06:13+00:00

when i click on my button am able to show date picker sucessfully.But when

  • 0

when i click on my button am able to show date picker sucessfully.But when i am selecting date from the date picker I am unble to show the selected date on UIbutton. plz help me

Here is my code:

-(IBAction)btnDateClicked:(id)sender
{ 
UIActionSheet *actionSheet1 = [[UIActionSheet alloc] initWithTitle:nil 
                                                          delegate:nil
                                                 cancelButtonTitle:nil
                                            destructiveButtonTitle:nil
                                                 otherButtonTitles:nil];

[actionSheet1 setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

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


UIDatePicker *pView=[[UIDatePicker alloc] initWithFrame:pickerFrame];

pView.datePickerMode=UIDatePickerModeDate; 

NSDateFormatter *df=[[NSDateFormatter alloc] init];

[df setDateFormat:@"MM/dd/yyyy"];

// NSDate *date=[df dateFromString:self.hController.fromDateTime];

// [pView setDate:date animated:YES];

self.datePicker=pView;

[actionSheet1 addSubview:self.datePicker];

[pView release];

UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];

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(dismissActionSheet1:) forControlEvents:UIControlEventValueChanged];

[actionSheet1 addSubview:closeButton];

[closeButton release];

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

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

self.actionSheet=actionSheet1;

[actionSheet1 release];
}
///////////////////////////////////
- (void)dismissActionSheet1:(id)sender
{
[self.actionSheet dismissWithClickedButtonIndex:0 animated:YES];

NSDateFormatter *df=[[NSDateFormatter alloc] init];

[df setDateFormat:@"MM/dd/yyyy"];   

//NSString *str=[df stringFromDate:self.datePicker.date]; 

//self.hController.selectDate=str;    
}
  • 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-11T02:06:15+00:00Added an answer on June 11, 2026 at 2:06 am

    You have to use UIPickerViewDataSource,UIPickerViewDelegate methods for this.Create an array of your dates Which you are showing in the pickerView and use the following method.

    - (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component 
    {
    
    [ closeButton setTitle:[NSString StringWithFormat:@"%@",[datesArray objectAtIndex:row]] forState:UIControlStateNormal];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a click able button to a MKAnnotation as seen in
I want to be able to click the button and have it copy this:
I want to be able to click a button and open a new form
I'm loading a jquery dialog with paramater on button click. (able to do) This
I need to show an overlay on button click.To achieve this i have written
I would like to show a dialog and still be able to receive button
I am creating one subForm from Main form on button click event of Main
I'd like to be able to show or hide a tableview with the click
I made a camera layout where two buttons existed.A click button and a share
I am trying to use some action when I click button in navigation controller.

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.