uitextfielddelegate

How to know when the delete button on decimal pad is clicked

二次信任 提交于 2019-12-05 07:40:41
问题 I have four textField s and each takes only one character, similar to the lock screen. I can input and move from one textField to next textField . Problem is when I want to delete and move to previous textField , I don't know when the delete button is clicked. I'm using: func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool to input and move from one textField to another. How do I know when the delete key is pressed? 回答1

How to get UITableViewCell's index from its edited UITextField

情到浓时终转凉″ 提交于 2019-12-05 06:27:55
I'm working on an iPhone based BI project. I have a UITextField in a UITextViewCell , the UITextFieldDelegate points to my UITableViewController , I haven't done any sub-classing for the UITextViewCell nor the UITextField . Now after the text field end editing on the delegate -(void)textFieldDidEndEditing:(UITextField*)textField I need to know the row index of the current cell I'm editing, is there any way to get the parent cell of the text field? Or can I set some property to the textfield like 'rowIndex' when I create the cell? I really need this value inorderto save the new text. Thank you.

UITextFieldDelegate vs UITextField control events

为君一笑 提交于 2019-12-04 18:38:15
问题 If I want to handle changes to a UITextField, such as the user typing in it; it seems like this can be done either by assigning a delegate to that text field, and then having the delegate implement shouldChangeCharactersInRange, or by adding a target to the textField, and handling the UIControlEventEditingChanged event. Aside from the fact that with the delegate method, you can return NO and therefor stop the user from making the edit, is there any difference between these 2 things? Same

Swift why strcmp of backspace returns -92?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 12:39:23
I was tried to detecting backspace inside of UITextfieldDelegate. And found this answer. https://stackoverflow.com/a/49294870/911528 And It working correctly. But I don't know what's going on inside of this function. let char = string.cString(using: String.Encoding.utf8)! let isBackSpace = strcmp(char, "\\b") if isBackSpace == -92 { print("Backspace was pressed") return false } I don't know why the result of cString of backspace is 0. I can debug on XCode. Please check the screenshot. I don't know why the strcmp about 0 for backspace(as far as I got this value on XCode debugger) and "\b"

Weird error while using UITextFieldDelegate

蓝咒 提交于 2019-12-04 06:22:43
问题 I have this error while messing with UITextField delegate: Can't find keyplane that supports type 8 for keyboard Wildcat-Landscape-QWERTY-Pad; using 3673479387_Wildcat-Alphabetic-Keyboard_Capital-Letters Someone have any idea what is it? Thanks in advance. 回答1: for iPad you can't use keyboard type: Decimal Pad ; you must change it to Number and Punctuation , etc 来源: https://stackoverflow.com/questions/16486312/weird-error-while-using-uitextfielddelegate

textFieldDidBeginEditing is called prematurely

荒凉一梦 提交于 2019-12-04 05:11:39
I have an application in which I have to scroll up in case of the keyboard showing. to get the keyboard size, I'm registering the UIKeyboardWillShowNotification event like so: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:self.view.window] This does work, the problem is, it is being called after the textFieldDidBeginEditing was called. So, I can't get the actual keyboard size, but only after the field is already in edit mode, which defeats the whole purpose of registering this event on the first place. I

Disable copy, paste in UITextfield is not working in iOS 9.x

主宰稳场 提交于 2019-12-04 03:41:54
问题 I created a text field in one class BBCustomUtility.h,.m class files and then +(UITextField*)createTextField: (CGRect)rect image:(NSString*)imageName tag:(int)tag secureText:(BOOL)entry placeh:(NSString*)placeholder { UITextField *transactionField = [ [ UITextField alloc ] initWithFrame: rect ]; transactionField.background = [UIImage imageNamed:imageName]; transactionField.adjustsFontSizeToFitWidth = YES; transactionField.textColor = [UIColor blackColor]; transactionField.font = [UIFont

Detecting a change to text in UITextfield

大憨熊 提交于 2019-12-03 15:01:37
问题 I would like to be able to detect if some text is changed in a UITextField so that I can then enable a UIButton to save the changes. 回答1: Take advantage of the UITextFieldTextDidChange notification or set a delegate on the text field and watch for textField:shouldChangeCharactersInRange:replacementString . If you want to watch for changes with a notification, you'll need something like this in your code to register for the notification : [[NSNotificationCenter defaultCenter] addObserver:self

UITextFieldDelegate vs UITextField control events

折月煮酒 提交于 2019-12-03 12:08:22
If I want to handle changes to a UITextField, such as the user typing in it; it seems like this can be done either by assigning a delegate to that text field, and then having the delegate implement shouldChangeCharactersInRange, or by adding a target to the textField, and handling the UIControlEventEditingChanged event. Aside from the fact that with the delegate method, you can return NO and therefor stop the user from making the edit, is there any difference between these 2 things? Same question for handling the beginning of editing or the ending of editing. It could be done either with the

Format UITextField text without having cursor move to the end

被刻印的时光 ゝ 提交于 2019-12-03 03:13:52
问题 I am trying to apply NSAttributedString styles to a UITextField after processing a new text entry, keystroke by keystroke. The problem is that any time I replace the text the cursor will jump the very end on each change. Here's my current approach … Receive and display text change immediately (same issue applies when I return false and do the text replacement manually) func textField(textField: UITextField!, shouldChangeCharactersInRange range: NSRange, replacementString string: String!) ->