gpt4 book ai didi

iphone - 点击 UITextField 时在 UIActionSheet 中显示 UIDatePicker

转载 作者:可可西里 更新时间:2023-11-01 03:06:43 26 4
gpt4 key购买 nike

我正在创建闹钟应用。我想在点击 UITextField 时在 UIActionSheet 中显示 UIDatePicker

最佳答案

为此,您需要实现 UIActionShetDelegateUITextFieldDelegatetextFieldDidBeginEditing 中,您需要显示如下操作表:

-(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)];

}

关于iphone - 点击 UITextField 时在 UIActionSheet 中显示 UIDatePicker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12096118/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com