uitextfield

Making a UISearchBar a drop-in replacement for a UITextField?

我只是一个虾纸丫 提交于 2019-12-12 03:06:14
问题 In interface builder, a UISearchBar seems styled to appear (as you would expect, considering how it is named) in a toolbar, whereas as UITextField is styled to look good on a blank page. Is there a way to make a UISearchBar that does not need to be in a "bar" - such as if you wanted to have multiple search-enabled textfields on a page? My ultimate goal is to have a page full of UITextFields - each of which pops up a predictive search popover as the user fills out the form. I can do the

How do I compare UITextfield input to different strings?

≯℡__Kan透↙ 提交于 2019-12-12 03:04:15
问题 I want to compare the value of the input from a UITextfield to some other strings. Here's my guessing. if ([textfield.text isEqualToString:@"First" || @"Second" || @"Third"]) { // do something } Is there any better approach to this? 回答1: In a situation where you have a series of objects such as your example, you would add then to an array and test its existence in the array: Example NSMutableArray *arr = [[[NSMutableArray alloc] init] autorelease]; [arr addObject:@"First"]; [arr addObject:@

How to update a UITextField when receiving input from a UIPickerView?

随声附和 提交于 2019-12-12 02:27:53
问题 Currently, I am programmatically creating a UITextField and UIPickerView within cellForRowAt . I can easily update the selected UIPickerView value within didSelectRow if I connect my UITextField to an IBOutlet . However, I require the UITextField to be created programmatically with applied AutoLayout constraints. However, I don't know how to update the UITextField as I have no reference to it in the UIPickerView's didSelectRow function since it's created programmatically within cellForRowAt

How to make keyboard with textfield on the top of it?

陌路散爱 提交于 2019-12-12 02:26:36
问题 I need to have textfield (maybe with button) fixed at the bottom of screen, and when start editing, I want it (and probably the whole view) to move with keyboard up - just like in the native Messages application (or Whatsapp, etc...). Any suggestions ? 回答1: The easiest way is to put everything in a UIScrollView, which you resize when the keyboard is shown using the UIKeyboardDidShowNotification. Then you scroll to ensure that your views are visible. Check out the Apple documentation under

Invalid capability and invalid name with custom keyboard

試著忘記壹切 提交于 2019-12-12 02:26:27
问题 I've designed a custom keyboard for the use of my own application only. That's why in fact, I didn't use UIInputViewController but only UIViewController (and set a delegate to the custom text field which is actually a subclassed UIScrollView ). When I call becomeFirstResponder() on my text field, it takes incredibly long (not only the first time but each time I call this function) until the keyboard actually appears (around 2 seconds). Furthermore I get the following error messages:

subclass override method not being called

懵懂的女人 提交于 2019-12-12 02:25:41
问题 I created a subclass of UITextField to override the method rightViewRectForBounds. Here is my custom class CustomTextField @interface CustomTextField : UITextField @end @implementation CustomTextField // override rightViewRectForBounds method: - (CGRect)rightViewRectForBounds:(CGRect)bounds{ NSLog(@"rightViewRectForBounds"); CGRect rightBounds = CGRectMake(bounds.origin.x + 10, 0, 30, 44); return rightBounds ; } @end Now I set up my ViewController to call the custom class instead of

TextField overlaid on ScrollView “Adjust to Fit” TextField not working

旧街凉风 提交于 2019-12-12 02:24:49
问题 I have a scroll view overlaid by two text fields, one near the top and one near the bottom. When text in the text field reaches the side constraints the app freezes up and does not adjust the size to fit the width. Initially, I had a image view overlaid by two text fields and it was working properly. I think this has some relation to the scroll view. In the interface builder, Adjust to Fit is checked and min font size set. I also have used the following statements and no avail. topTextField

How to navigate to next UIViewController using UITextView in an UINavigationBar

走远了吗. 提交于 2019-12-12 02:14:09
问题 I'm trying to use an UITextView as a button, and after clicking on the UITextView it should pop to to another UIViewController (not the root one, next one). Using an UIButton works fine (by dragging to next UIViewController and choosing "Push" as the segue type, without doing any coding). But, doing the same thing with a UITextView does not work! So, my question is how to navigate to the next view controller using an UITextField? 回答1: Try adding a UITapGestureRecognizer to the text view and

Notifications of backspace key iOS

前提是你 提交于 2019-12-12 02:07:41
问题 Is there a way to get notifications of when the user presses the backspace key on a UITextField, even if the field is empty? I would like to be able to trigger some code when the user backspaces on an empty field. 回答1: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextFieldTextDidChangeNotification object: nil]; This is how you get notified on every key the user presses. Then you have to figure out (i think in the notification is a property

iOS: dynamically adding data from UITableView to NSArray

十年热恋 提交于 2019-12-12 01:57:34
问题 I have a UITableView in which I have a custom prototype cell, defined in another class (CustomCell), with a UITextField in it. Every time I press a button, it calls a method called addItem, which creates a new cell. I want the texts in the UITextFields to go to an array. To try to explain it better, if I add 3 cells to the UITableView and input 3 texts in the corresponding UITextFields, I want the text in 1st cell to go to the array in index 0, the text in the 2nd to go to index 1 and the