uitextfield

Detect UISearchBar focus on the text field

我只是一个虾纸丫 提交于 2019-12-05 05:59:28
Is there a way to detect if a user has click on the searchbar textfield and the keyboard has appear ? From the docs , searchBarTextDidBeginEditing: searchBarCancelButtonClicked: If you are implementing UISearchBarDelegate, the first method that should be called is: - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar { //do stuff return YES; } Here's the class reference: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UISearchBarDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UISearchBarDelegate/searchBarShouldBeginEditing : Your searchbar

Textview with Suggestions List in iOS

♀尐吖头ヾ 提交于 2019-12-05 05:41:25
I am trying to implement a textView in which when user starts typing(Let's say names) it would show up the suggestions and when they click them it gets added to the textView than user presses comma and again the same functionality for another name.... And at the end the text in the textView should look like this... Aron,Maria,Alex,Cassie Can any one suggest me How can I achieve this? (Its somewhat similar to adding the "Tags" while posting this question!!!) Thanks. You can use a NSTokenField replacement there is some libraries here : tokenField libraries Following link may help you: http://www

UITextField autocapitalizationType UITextAutocapitalizationTypeAllCharacters not working on device

别来无恙 提交于 2019-12-05 05:31:27
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: - (void)textFieldDidBeginEditing:(UITextField *)textField { NSLog( @"textField.autocapitalizationType=%d

Reactive Cocoa - UITextView's rac_textSignal doesn't get called when programmatically setting text

送分小仙女□ 提交于 2019-12-05 05:19:10
I'm implementing a chat UI, and using Reactive Cocoa to adjust the chat bubble's size as the user types. Currently, I'm updating the UI's layout based on the textview's rac_textSignal . Everything's working great - except for one bit: when the user sends the message, I programmatically clear the textfield: _inputTextView.text = @""; ... but the textview's rac_textSignal doesn't activate. I hear this is a feature with ReactiveCocoa - but what's the proper way to build this? Do I need to have an NSString holding the currentlyTypedString , and drive the UI changes when that string updates? Yep,

UITextPosition to Int

荒凉一梦 提交于 2019-12-05 05:00:31
I have a UISearchBar on which I am trying to set a cursor position. I am using UITectField delegates as I couldn't find anything direct for UISearchBar. Below is the code I am using: UITextField *textField = [searchBar valueForKey: @"_searchField"]; // Get current selected range , this example assumes is an insertion point or empty selection UITextRange *selectedRange = [textField selectedTextRange]; // Construct a new range using the object that adopts the UITextInput, our textfield UITextRange *newRange = [textField textRangeFromPosition:selectedRange.start toPosition:selectedRange.end];

How to auto fetch OTP, if we use multiple text fields

一曲冷凌霜 提交于 2019-12-05 03:53:19
I know that if we want to auto fetch the OTP(if we use single textfield) we need to use otpTextField.textContentType = .oneTimeCode But, If we use multiple textfield(According to following image) how should we achieve this ? Natarajan If you can get the auto OTP for single field, you can split that text into your four text fields. I believe. You may have to use textField's change observer as like below, textField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged) func textFieldDidChange(_ textField: UITextField) { // here check you text field's input Type if

Hide keyboard on touch outside of textfield

旧城冷巷雨未停 提交于 2019-12-05 03:09:20
问题 I'm trying to hide the keyboard after a touch anywhere else on the screen. The code I'm using is based on this answer here. IBOutlet UITextView *myTextView; And the method: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; if ([myTextView isFirstResponder] && [touch view] != myTextView) { [myTextView resignFirstResponder]; } [super touchesBegan:touches withEvent:event]; } What I don't understand is how I should link my

Set UITextField placeholder color programmatically

本小妞迷上赌 提交于 2019-12-05 02:50:41
How to set UITextField place holder color programmatically in swift? 1 - Create an AttributedString with colour you want. 2 - Set this AttributedString to the textfield attributedPlaceholder property let placeholder = NSAttributedString(string: "Some", attributes: [NSForegroundColorAttributeName : UIColor.redColor()]) let textField = UITextField(frame: CGRect(x: 0, y: 0, width: 100, height: 30)); textField.attributedPlaceholder = placeholder; self.view.addSubview(textField) From apple documentation var attributedPlaceholder: NSAttributedString! This property is nil by default. If set, the

Increase UITextField to Certain Length

空扰寡人 提交于 2019-12-05 02:43:29
问题 I have a UITextField that I would like to "automatically" adjust its bounds size in order to make space for the string added in the field. However, I would like it to max-out in terms of width at a certain amount. What is the best way that I can go about doing this? Thanks for any help. EDIT: TestingView.h #import <UIKit/UIKit.h> @interface TestingView : UIView <UITextFieldDelegate> { } @end TestingView.m #import "TestingView.h" @implementation TestingView - (void)awakeFromNib { CGRect

Add UITextField to title view of navigation item

时间秒杀一切 提交于 2019-12-05 01:47:26
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]; 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.navigationBar.frame.size.width, 21.0)]; self.navigationItem.titleView = textField; [textField