简体   繁体   English

出现视图时如何自动显示键盘

[英]How to display the keyboard automatically when a view appears

显示视图时如何使键盘出现?

在 viewDidAppear 或 viewWillAppear 中尝试此代码

textfieldname.becomeFirstResponder() 

Update for SwiftUI 3 SwiftUI 3 更新

If you are using UIViewRepresentable, you can use .becomeFirstResponder() there.如果你使用 UIViewRepresentable,你可以在那里使用.becomeFirstResponder()

将以下代码放入ViewDidLoad

textfieldname.becomeFirstResponder()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在iOS上不执行任何操作的情况下点击搜索栏以自动显示视图时出现的键盘,目标C - How to tap on searchbar to appear the keyboard automatically when view appears without doing anything in iOS, objective C 如何在视图出现的同时显示键盘并向上移动 UIView? - How do I display the keyboard and move up the UIView at the same time when the view appears? 键盘出现时如何在可见框中心移动视图? - How to move view at the center of visible frame when keyboard appears? 出现键盘时如何使滚动视图在缩小的视图区域中滚动 - How to make the scrollview scrollable in reduced view area when keyboard appears 如何在键盘出现时使视图控制器滚动到文本字段 - How to make the view controller scroll to text field when keyboard appears NativeScript - ios 出现键盘时如何调整视图 - NativeScript - ios how to adjust view when keyboard appears IOS / Xcode:键盘出现时如何向上移动查看 - IOS/Xcode: How to Move View Up when Keyboard appears 如何在iOS(Cordova)上显示键盘时调整Web视图的大小 - How to resize web view when keyboard appears on iOS (Cordova) 当键盘出现时,如何保持UITableView在视图中? - How can I keep UITableView in view when keyboard appears? 键盘出现时如何向上移动集合视图controller? - How to move up collection view controller when keyboard appears?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM