当选择器视图出现时如何与键盘出现类似地滚动屏幕?
我有一个如图所示的屏幕。现在我希望当用户单击提交的文本时会出现一个选择器视图。所以我希望当选择器视图出现时,视图将在键盘出现时类似地自动滚动。
当选择器视图出现时怎么办?
提前致谢...
I have a screen which i shown in image. Now i want that when user click on text filed then a picker view appears. So i want that when picker view appear then view will scroll automatically similarly when keyboard appear.
How do that when picker view appears?
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你应该在 gitHub 上看看这个伟大的项目:
https://github.com/reednj/TDSemiModal
它提供了一个类,使选择器看起来像键盘,并将连接的字段移动到视图中。
You should have a look at this great project on gitHub:
https://github.com/reednj/TDSemiModal
It provides a class for making a picker appear like the keyboard, with moving the connected field into view.
我假设您希望您的应用程序是纵向的,因为如果它是横向的,您可以进行更改。将
UIPickerView
添加到您的笔尖并将其连接到IBOutlet
。然后,使用IBAction
方法创建一个按钮,为UIPickerView
提供动画效果。尝试在 .h 文件中:和在 .m 文件中:
确保将笔尖中的
UIPickerView
设置为 480 坐标,因此它位于视图下方。编辑:如果您希望将
UIPickerView
连接起来并充当UITextField
或的键盘>UITextView
,您始终可以将其连接到UITextField
的.inputView
属性,这样也可以工作。希望有帮助!
I will assume that you want your app to be in portrait, as you can make the changes if it is landscape. Add a
UIPickerView
to your nib and hook it up to anIBOutlet
. Then, make a button with anIBAction
method that animates theUIPickerView
. Try in the .h file:and in your .m file:
Make sure you set your
UIPickerView
in the nib to have a y coordinate of 480, so it is below the view.Edit: If you want the
UIPickerView
to be hooked up and act like the keyboard of aUITextField
orUITextView
, you could always hook it up to the.inputView
property of theUITextField
, and that would work as well.Hope that Helps!