resignfirstresponder

SwiftUI dismiss keyboard when tapping segmentedControl

こ雲淡風輕ζ 提交于 2021-02-19 01:15:50
问题 I have a TextField in SwiftUI that needs to use a different keyboard depending on the value of a @State variable determined by a SegementedControl() picker. How can I dismiss the keyboard (like send an endEditing event) when the user taps a different segment? I need to do this because I want to change the keyboard type and if the textField is the responder, the keyboard won't change. I have this extension: extension UIApplication { func endEditing() { sendAction(#selector(UIResponder

IOS 7 UITextField resignFirstResponder BAD

萝らか妹 提交于 2020-01-01 02:41:26
问题 Im getting a crash, when using a UItextField, inside my customCell, and when i resignFirstResponder the textfield, but its not visible anymore(the table view scrolled out of window). I still can find the textfield, the pointer continues accessible, it is no null, and the crash only occurs on IOS7, on IOS6 i dont have this problem. Heres some code : The textField is a global variable. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

Dismiss keyboard of TextField programmatically

落花浮王杯 提交于 2019-12-25 02:23:03
问题 I know how to use the following method by Interface Builder. -(void)dismissKeyboard { [testTextField resignFirstResponder]; } In this way, when I touch the area outside the keyboard or tap the "return", the keyboard will dismiss. But I don't know how to make it all by code. Please teach me , thanks. Here's .h #import <UIKit/UIKit.h> @interface SecondViewController : UIViewController { UITextField *testTextField; } @property (nonatomic,retain) UITextField *testTextField; @end here's .m #import

Dismiss keyboard for UITextView without using Return key

亡梦爱人 提交于 2019-12-23 20:06:08
问题 I'm using a UITextView and want to keep the normal usage of Return key, i.e. to insert a new line. But how do I dismiss the keyboard when I can't use the Return key for that? 回答1: A lot of people add a UIToolbar with a Done button on it above the keyboard. This is how the Safari app does it as well and in my opinion it is the best way to handle this situation. See a pic here. To dismiss the keyboard, you just have to do [textField resignFirstResponder];. Here is an okay example of how to add

Auto Resign and assign first responder in text field in Swift

心不动则不痛 提交于 2019-12-23 04:48:24
问题 I have taken 3 text fields and want them to hold just one integer for OTP purpose (It's the need of the project design). When user enters number in first textfield, the responder should automatically get assigned to the second text field and then to the third text field. As soon as user enters last OTP digit in the third textfield, I want to hit the webservice. What I did so far is : class ActivationCodeVC: UIViewController, UITextFieldDelegate then otpField1.delegate = self otpField2

Understanding resignFirstResponder with UITextField

与世无争的帅哥 提交于 2019-12-20 14:23:20
问题 I'm trying to get rid of the keyboard when the user touch outside my UITextField, by using this method: - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [mainTextController resignFirstResponder]; [super touchesBegan:touches withEvent:event]; } However, this seems to call a method that is called after pressing the return button on the keyboard, but I just want the keyboard to vanish, not to press return for me. How can I accomplish that? Thanks! EDIT: tGilani's answer is the

Understanding resignFirstResponder with UITextField

纵饮孤独 提交于 2019-12-20 14:22:05
问题 I'm trying to get rid of the keyboard when the user touch outside my UITextField, by using this method: - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [mainTextController resignFirstResponder]; [super touchesBegan:touches withEvent:event]; } However, this seems to call a method that is called after pressing the return button on the keyboard, but I just want the keyboard to vanish, not to press return for me. How can I accomplish that? Thanks! EDIT: tGilani's answer is the

UITextField's keyboard won't dismiss. No, really

亡梦爱人 提交于 2019-12-18 12:16:53
问题 I have a table view in a modal form sheet (iPad), and one of the cells contains a UITextField. My view controller holds a reference to the text field and is also its delegate. When the text field hits Return, I tell it to -resignFirstResponder inside of -textFieldShouldReturn: . In another case, I want to force it to end editing, so I tell the whole table view to -endEditing:YES . Afterwards I release my local reference to the text field, and reload the row to replace it with something else.

UITableView reloadData automatically calls resignFirstResponder

只谈情不闲聊 提交于 2019-12-17 10:38:20
问题 I have this UITableView with custom cells that can get only predefined values, therefore I use a UIPickerView as their inputView. All is jolly good until I edit a field and need to show its updated value. In order to make things clearer and easier to maintain, I made delegates and data sources as separate classes, and use notifications to make them interact with the tableView. So, after a value has been chosen from the UIPickerView, the tableView's data source gets notified, and in turn

Receiving RemoteControlEvents to First Tab when interacting in Second Tab in a TabBar Controlled iOS App

孤人 提交于 2019-12-12 14:47:02
问题 I am developing an iOS app with a tab bar controller. In the first tab, I placed an instance of AVQueuePlayer to start playing music from the web. I did all coding to allow play and pause events through remote control events. But I could able to receive remote control events only when I stay in the first tab. When I switch to other tabs, remote control events are not received to the first tab. When I place the following lines in first tab view controller, I can receive remote control events