iOS-取消显示为inputView的UIDatePicker [英] iOS - Dismiss UIDatePicker presented as inputView

查看:119
本文介绍了iOS-取消显示为inputView的UIDatePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UI的文本字段,当它的选择呈现出的UIDatePicker而不是默认的键盘,我怎么能建立一个按钮,当用户完成关闭该选择器?

I have a text field in my UI that when it's selected presents a UIDatePicker instead of the default keyboard, how could I set up a button as to dismiss the picker when the user is done?

推荐答案

我要做的是将inputView作为自定义视图,其中包含一个UIDatePicker和一个位于其上方的工具栏,其中的完成"按钮与方法连接在一起调用委托方法来告诉拥有UITextField的对象通过调用resignFirstResponder消除键盘".

What I do is have my inputView as a custom view which contains a UIDatePicker and a toolbar above it with a 'Done' button wired up to a method that calls a delegate method to tell the object that owns the UITextField to dismiss the "keyboard" by calling resignFirstResponder.

这篇关于iOS-取消显示为inputView的UIDatePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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