8
For doing this you need to implement UIActionShetDelegate and UITextFieldDelegate
In the textFieldDidBeginEditing you need to show the action sheet like:
-(void)textFieldDidBeginEditing:(UITextField *)sender
{
[self showAction];
}
-(void) showAction
{
UIActionSheet *asheet = [[UIActionSheet alloc] initWithTitle:@"Pick the date." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Select", nil];
[asheet showInView:[self.view superview]];
[asheet setFrame:CGRectMake(0, 117, 320, 383)];
[asheet release];
}
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, 320, 216)];
//Configure picker...
[pickerView setMinuteInterval:5];
[pickerView setTag: kDatePickerTag];
//Add picker to action sheet
[actionSheet addSubview:pickerView];
[pickerView release];
//Gets an array af all of the subviews of our actionSheet
NSArray *subviews = [actionSheet subviews];
[[subviews objectAtIndex:SelectButtonIndex] setFrame:CGRectMake(20, 266, 280, 46)];
[[subviews objectAtIndex:CancelButtonIndex] setFrame:CGRectMake(20, 317, 280, 46)];
}