我在UIActionSheet
中展示了一个截取器,非常简单直到iOS 8。现在,他们似乎已经打破了最新更新的能力。它从来没有得到过支持,并且这种做法一直在文档中受挫。iOS 8在UIActionSheet中破解了UIPickerView
据推测,整个UIActionSheet
功能已被弃用,并且将不会继续支持。该文档说,使用UIAlertController代替。
我试过切换到UIAlertController
,实际上发现我最初的预期是比我原来提出的更好的解决方案。
我的原代码:
// Ask user for project to associate the new issue with a project
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Select Project", @"Title for Action Sheet")
delegate:self
cancelButtonTitle:klocalized_CancelButtonTitle
destructiveButtonTitle:nil
otherButtonTitles:klocalized_SelectButtonTitle ,nil];
[menu addSubview:self.projectPicker];
[menu showFromTabBar:self.tabBarController.tabBar];
[menu setBounds:CGRectMake(0, 0, 320, 700)];
在iOS的7
我的新代码工作的罚款。看起来更好,但由于某种原因,我无法获得UITextField
尊重我的inputView
属性的设置。它显示我的文本字段与标准键盘,否则这将是一个可以接受的选择,甚至比原来在我看来更好。
新建,正在进行的工作为iOS 8:
// is iOS 8, ActionSheet, newly deprecated, will not allow subviews. Use UIAlertController instead
NSString *title = NSLocalizedString(@"Select Project", @"Title for Action Sheet");
UIAlertController *projectSelector = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
[projectSelector addAction:[UIAlertAction actionWithTitle:klocalized_CancelButtonTitle style:UIAlertActionStyleCancel handler:nil]];
[projectSelector addAction:[UIAlertAction actionWithTitle:klocalized_SelectButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// Do my button action stuff here
}]];
[projectSelector addTextFieldWithConfigurationHandler:^(UITextField *textField) {
// projectField is lazily created property.
//My picker is set as its inputView but standard keyboard is always presented instead.
textField = self.projectField;
}];
[self presentViewController:projectSelector animated:YES completion:^{
// Do my final work here
}];
谁能告诉我为什么发生这种情况?是inputView
UITextfield
财产在新的UIAlertController
视图上无法使用?有没有人以这种方式使用UIPickerView
?
我没有包含我的代码projectField
或projectPicker
属性,但我已经过测试和检查。他们确实创建有效的对象。选择器由我提交的VC保留,并且文本字段很弱,我假设我拥有AlertViewController。我试图保留它,但没有效果。
我确实收到UITextField
委托来自文本字段的调用,所以我知道它是我创建的对象。当我清楚地将pickerView设置为inputView
时,我可以想象没有标准键盘显示的原因。在截图
查看结果视图: