uitextfield

Replacing UITextField input with a UIDatePicker

守給你的承諾、 提交于 2019-12-22 05:31:59
问题 I have a table view controller with (among others) a cell that is to represent a date. I followed this post "How do I make a modal date picker that only covers half the screen?" and I have it working with one big exception - I can't get the picker to disappear! I tried registering for the event UIControlEventTouchUpOutside, but it seems that this is not generated by the picker (or at least in the mode that I am using it). How can I recognize that the user has finished selecting a date? Also,

How to add UILongPressGestureRecognizer to a UITextField?

旧巷老猫 提交于 2019-12-22 05:10:12
问题 I am trying yo add UILongPressGestureRecognizer to one of UITextField on page but It does not call the selector method when Long Press the UiTextField. I added it to UItextField But it does not call the Selector method when I Long press the TextField but Showing the Magnifier on Field. [self.tfCustomerStreet addGestureRecognizer:LongPressgesture]; But it works fine and call the selector Method if I add it to the View. [[self view] addGestureRecognizer:LongPressgesture]; Initialization code in

UITextField autocapitalizationType UITextAutocapitalizationTypeAllCharacters not working on device

喜夏-厌秋 提交于 2019-12-22 05:06:25
问题 You can set the autocapitalizationType property of a UITextField so all input is in upper case. I find that does work fine on the simulator (when actually tapping the simulator's keypad, not the Mac's keyboard), but not on the device? Everything stays lowercase. In the UICatalog demo I added to the textFieldNormal method: textFieldNormal.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters; Added a delegate too, to display the actual autocapitalizationType for the UITextField: -

How to disable copy/paste option in UITextfield in ios7

回眸只為那壹抹淺笑 提交于 2019-12-22 04:26:06
问题 I tried @implementation UITextField (DisableCopyPaste) -(BOOL)canPerformAction:(SEL)action withSender:(id)sender { return NO; return [super canPerformAction:action withSender:sender]; } @end But it disables all textfield's copy/paste option,how to disable the menu options for specific textfield. 回答1: I think this method is ok,since no making of category etc.It works fine for me. [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [[UIMenuController sharedMenuController] setMenuVisible:NO

Add UITextField to title view of navigation item

£可爱£侵袭症+ 提交于 2019-12-22 03:47:02
问题 How do you add a text field to the title view of a navigation item and have it sized correctly? It works fine if I do this with a search bar like this but I don't know how to get a text field to size itself in the same way as a search bar. myViewController.navigationItem.titleView = [UISearchBar new]; 回答1: As my comment suggested, try the following, which seems to me is what you're after. UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, self.navigationController

How to figure out the current caret position in a UITextField?

雨燕双飞 提交于 2019-12-22 01:19:03
问题 I want to programmatically paste a string into a text field or text view at the current caret position. Is there an easy way to do this? I would need to know the current caret position, but there's no method to retrieve it, right? Don't want to call private API. Is there any legal way to do it? 回答1: Use UITextView 's selectedRange method. If the range has a non-zero length (in the case of the user having selected some text), just take the location (or NSMaxRange() , or replace the entire

Limiting NSString to numbers as well as # if chars entered. (code included)

青春壹個敷衍的年華 提交于 2019-12-22 00:11:47
问题 I have searched the site for my answer, however I think it is also how I got myself into this problem. I'm trying to limit my 1 and only text field to 10 characters and only numbers. Below is code mostly off other questions on this site. What I am trying to do is mash this code together for my limits - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSCharacterSet *cs = [[NSCharacterSet

How to enable or disable the keyboard return key [duplicate]

拈花ヽ惹草 提交于 2019-12-21 19:55:45
问题 This question already has answers here : How to disable/enable the return key in a UITextField? (7 answers) Closed 4 years ago . When we enter character in textfield then it is enabling the return key. But in our requirement we need to enable the return key when length is more than 5. But now as soon as we enter character it is enabling the return key. Do we need to customize the keyboard or is there any other solution available. Thanks in advance. 回答1: Well I think you should handle it in

Restrict UITextField size

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 18:56:11
问题 How can I limit the number of characters in a UITextField? I.e if I limit it to 10 characters, the user will be unable to enter more than 10. Also I want to prevent him from entering some special characters like +, =, etc. How would I do this? 回答1: Here is a code sample to limit the size of a UITextField: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if ([[textField text] length] + [string length] - range.length

UITextField doesn't end editing when Button clicked( delegate textFieldDidEndEditing )

主宰稳场 提交于 2019-12-21 17:18:40
问题 I have two textFields on the screen and a Submit button . User inputs details in first textField and then the second one. My requirement is to end the editing when Submit button is clicked and print the user inputs in these textFields .I am having issues printing the second textField's value, as the editing never seems to end when the user clicks the Submit button . Here is my code. Appreciate your help on this issue (I have added the textfield delegate) import UIKit class ViewController: