uitextfield – iOS 8破坏了UIActionSheet中的UIPickerView

uitextfield – iOS 8破坏了UIActionSheet中的UIPickerView,第1张

概述我在UIActionSheet中提出了一个非常简单的选择器,直到iOS 8.现在,它似乎已经破坏了最新更新的功能.它从未得到支持,并且在文档中始终不鼓励这种做法. 据推测,整个UIActionSheet功能已被弃用,未来将不再支持.文档说使用UIAlertController代替. 我已经尝试过切换到UIAlertController,并且实际上发现了我最初的预期,这将是一个比我最初提出的更好的解 我在UIActionSheet中提出了一个非常简单的选择器,直到iOS 8.现在,它似乎已经破坏了最新更新的功能.它从未得到支持,并且在文档中始终不鼓励这种做法.

据推测,整个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,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        }];

谁能告诉我为什么会这样? UITextfIEld的inputVIEw属性在新的UIAlertController视图中是不可用的吗?有没有人以这种方式成功使用UIPickerVIEw?

我没有包含我的projectFIEld或projectPicker属性的代码,但我已经测试和检查.他们确实创建了有效的对象我的演示VC保留了选择器,文本字段很弱,由我假设的AlertVIEwController拥有.我试着保留它,这没有效果.

我也从文本字段接收UITextFIEld Delegate调用,所以我知道它是我创建的对象.当我清楚地将pickerVIEw设置为inputVIEw时,我认为没有理由显示标准键盘.

查看截图中的结果视图:

解决方法 在将我的头撞在桌子上一段时间之后,我找到了解决方案,好吧,我的意思是我发现了我正在制造的愚蠢错误.

我正在向后执行textFIEld配置.我认为目的是传递textFIEld参数我的文本字段,当我应该设置给定的文本字段的属性.

只需改为

// is iOS 8,@"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) {        }]];        [projectSelector addTextFIElDWithConfigurationHandler:^(UITextFIEld *textFIEld) {            //Set the propertIEs of the textFIEld provIDed. DO NOT CREATE YOUR OWN.            [textFIEld setPlaceholder:NSLocalizedString(@"Make Selection",@"PlaceHolder for project fIEld when awaiting picker choice")];            [textFIEld setinputVIEw:self.projectPicker];            [textFIEld setDelegate:self];            self.projectFIEld = textFIEld;        }];        [self presentVIEwController:projectSelector animated:YES completion:^{        }];
总结

以上是内存溢出为你收集整理的uitextfield – iOS 8破坏了UIActionSheet中的UIPickerView全部内容,希望文章能够帮你解决uitextfield – iOS 8破坏了UIActionSheet中的UIPickerView所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1042925.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存