gpt4 book ai didi

iOS7 和带有时间选择器的 UIActionSheet

转载 作者:行者123 更新时间:2023-12-01 17:55:00 26 4
gpt4 key购买 nike

我有一个 iOS6 应用程序,它使用以下代码创建带有时间选择器的 UIActionSheet:

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, 320, 216)];

//Configure picker...
[pickerView setMinuteInterval:5];
[pickerView setTag: 4];
[pickerView setDatePickerMode:UIDatePickerModeTime];

//Add picker to action sheet
[actionSheet addSubview:pickerView];

//Gets an array of all of the subviews of our actionSheet
NSArray *subviews = [actionSheet subviews];

[[subviews objectAtIndex:1] setFrame:CGRectMake(20, 266, 280, 46)];
[[subviews objectAtIndex:2] setFrame:CGRectMake(20, 317, 280, 46)];
}

在我在 iOS7 中尝试之前,它就像一个魅力,当我单击弹出操作表的输入字段时它总是崩溃。这是输入字段后面的代码:
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
selectedTag = textField.tag;

// the input field that needs to show the actionsheet has tag 1.
if (selectedTag == 1) {
UIActionSheet *asheet = [[UIActionSheet alloc] initWithTitle:@"Select a time:"
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
otherButtonTitles:@"Select", nil];

[asheet showInView:[self.view superview]];
[asheet setFrame:CGRectMake(0, 110, 320, 500)];

textField.userInteractionEnabled = NO;
}
textField.userInteractionEnabled = YES;
}

当应用程序崩溃时,我收到以下消息:

enter image description here

最佳答案

如果您希望在单击文本字段时显示日期选择器,您可以直接显示日期选择器。将日期选择器作为文本字段的输入 View 。

    pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, 320, 216)];

//Configure picker...
[pickerView setMinuteInterval:5];
[pickerView setDatePickerMode:UIDatePickerModeTime];
[dateTextField setInputView:pickerView];

关于iOS7 和带有时间选择器的 UIActionSheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19495902/

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