如何在iOS8的UIAlertController中添加UIDatePicker? [英] How to add UIDatePicker in UIAlertController in iOS8?

查看:138
本文介绍了如何在iOS8的UIAlertController中添加UIDatePicker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个已经随iOS-7发布的项目.但是现在由于操作表出现了问题,因此我现在正在实现UIAlertController.以下是我用来显示带有UIPicker的UIAlertController的代码.

I am working on a project which I had already released with iOS-7. But now as the action sheet is making problem so I am now implementing UIAlertController. Following is the code which I am using for showing UIAlertController with UIPicker.

alertController = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

        UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleDefault handler:nil];
        [alertController addAction:alertAction];
        [alertController addAction:alertAction];
        [alertController addAction:alertAction];
        [alertController addAction:alertAction];
        [pickerToolbar setFrame:CGRectMake(0, 0, self.view.frame.size.width-20, 44)];
        [alertController.view addSubview:pickerToolbar];
        [alertController.view addSubview:picker];

        [alertController.view setBounds:CGRectMake(0, 0, self.view.frame.size.width, 485)];
        [self presentViewController:alertController animated:YES completion:nil];

但是我无法在其中添加日期选择器.它无法正常工作,并且应用程序挂起.请为任何在UIAlertController中添加UIDatePicker的示例代码提供建议.预先感谢

But I am not able to add datepicker in it. It is not working same as normal picker and the app hang. Please advice for any sample code for adding UIDatePicker in UIAlertController. Thanks in advance

推荐答案

在操作表中添加UIDatePicker.从iOS 7开始,Apple引入了内联日期选择器的使用(请参阅日历"应用程序中的操作).

Adding UIDatePicker to action sheet was discouraged by Apple all along. Since iOS 7, Apple had introduced the use of inline date picker (see how it is done in the Calendar app).

如果您设法使用UIAlertController破解了变通办法,则它可能会在将来的iOS版本中再次中断.

If you managed to hack a workaround using UIAlertController, it may probably break again in future iOS releases.

这篇关于如何在iOS8的UIAlertController中添加UIDatePicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆