UIAlertView 中的时间选择器 [英] Time Picker in UIAlertView

查看:25
本文介绍了UIAlertView 中的时间选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个要求输入时间的弹出窗口,我认为使用 alertview 是可行的方法,但我不知道从哪里开始将时间选择器嵌入到 alertview 中.

I'm in need of a popup that asks for a time input, I figured an alertview would be the way to go but I have no idea where to begin embedding a time picker into an alertview.

除非有更好的方法来做到这一点?

Unless there is a better way of doing this?

推荐答案

对于其他人,我将评论中的问题改成了这样的时间选择器:

For anybody else, I adapted the question in the comments to be a time picker like so:

let vc = UIViewController()
vc.preferredContentSize = CGSize(width: 250,height: 300)
let pickerView = UIDatePicker(frame: CGRect(x: 0, y: 0, width: 250, height: 300))
vc.view.addSubview(pickerView)
let editRadiusAlert = UIAlertController(title: "Choose ETA", message: "", preferredStyle: UIAlertControllerStyle.alert)
editRadiusAlert.setValue(vc, forKey: "contentViewController")
editRadiusAlert.addAction(UIAlertAction(title: "Set ETA", style: .default, handler: nil))
editRadiusAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(editRadiusAlert, animated: true)

这篇关于UIAlertView 中的时间选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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