I have a table with several textFields in several cells, each with different input keyboards (numeric for phone number, standard for name, etc.).
When I change the editing text field by selecting one when other is editing, I want the first text field to hide the keyboard (the one which is being used) and only then the new keyboard to appear.
But putting [textField resignFirstResponder] doesn't solve my problem (the new one appears without the other disappearing, making the animation unnoticeable).
I tried to put the thread sleeping, but it didn't work as I wished.
Is there a way to have this animation?
Thanks a lot.
Related
I am a very basic SWIFT Xcode programmer. I make small apps.
For last 2 days, I am stuck at a very simple thing and I am sure with your guidance I can quickly make a decision.
I have a UIViewController class as well as an xib
In the layout I have 4 textfields
Now based on a user setting (in another frame user make a choice), I will either have to show 4 textfields ** OR ** 3 textfields and a UISwitch.
Long story short, if user select one option he should see UISwitch and 3 textfields or else 4 textfield. The labels's text also change.
To my limited knowledge, I will make another UIViewController, another XIB file and if user selection allows I will segue to the new UIViewController.
But all this looks so redundant. How do you smart people do this thing?
(Edit)
I use size classes in my layout as well as constraints in the visual editor for positioning of elements on the layout. If I change things programmatically, which is one option, how will I manage the layout ?
Please advise.
Show me the right path please.
When user select first option based on action show or hide the text field or switches, like when user select first option only show three text field and one UIswitch hide fourth text field.
And programatically change text field hint value and also set NSString Tag="first" so that when you want that value at the time of submit button you can apply if condition to tag and on that basis you can get your desired output on each selection.
Short version: I have a working solution using a UISegmentedControl but I don't like how it looks. When I use Safari, it "dims" either previous or next when it's at the beginning or end of the list of input fields. I can't convince a UISegmentedControl to do that, so how did they do it?
Long version:
I have a UITableView with cells that have text fields. The text fields take numeric inputs (floating point numbers, generally). That means I present the keyboard with keyboardType = UIKeyboardTypeDecimalPad. That also means no return button, so I need a good method to move between cells OTHER THAN touching the cells. I'd like to do it the same way as, say, iOS Safari does it - with a little toolbar that says "previous | next ... done."
I have code that does all of that (sets the textField.inputAccessoryView to be an instance of a UIToolbar with the appropriate buttons), using a UISegmentedControl for the previous and next button. I have that working so that next moves to the next cell and previous moves to the previous cell.
So why am I here? I can't get the dimmed previous/next behavior seen in iOS Safari to work with a UISegmentedController and I don't really want to implement all of that myself if I don't have to (at that point, my CCB will invoke one of the two rules it uses to reject changes: Rule 1) If I don't think it's a good idea, then I won't implement it; Rule 2) If it's easy, I'll probably do it).
(I would have posted pictures, but I'm too new to SO - sorry)
When I try to do the same thing it looks and acts like a Safari middle text field, but I can't seem to get it to look like the Safari version of first or last text field.
I've tried enabling, selecting, even changing the bar background color, but none of them seemed to work. The background color seemed to get closest, but I had to have 3 different toolbars based on when it was first, last, or middle, and even then it wasn't great.
Solved. The issue was that the "enabled" setting of the various segments as set in IB does not make it to the executable. I have to programmatically disable the previous or next segment in the view controller. Once I did this, it now appears as I want it.
When I set up the UISegmentedControl in IB, I set one segment to enabled and the other to disabled (== not enabled). In the debugger I started trolling through the settings of the various segments and found that actually setting the segment to disabled makes it work in the way I wanted.
For example, in the "nextToolbar" that contains a UISegmentedControl that is attached to "nextControl," only the Next button should be shown as active. That means I have to set the Previous button to disabled. The Previous button is at index 0, so disabling it means to do this somewhere before it's used (I put this in viewDidLoad:):
[self.nextControl setEnabled:NO forSegmentAtIndex:0]
Similarly, for the prevControl, where only the Previous button should be active, I use:
[self.previousControl setEnabled:NO forSegmentAtIndex:1]
Does anyone know how to change the word completion view's frame ?
The view appears when you type in some characters in a text view. but it always appears on the bottom of the character you type.
I found that iPhone message and Skype has put it to the top of the textView, how did they do that? should I define the keyboard myself or just implements some delegate methods?
From what I observe, the autocorrect suggestion is automatically positioned above the line where text is being typed if it is close enough to the on-screen keyboard, such that placing the suggestion below would cause the keyboard to obscure it.
My best guess is that this is determined and handled by the system and that there aren't any APIs to control where the suggestion appears, how to style it, etc.
I have a weird behaviour that has only shown up in the last week. I don't use IB, all the controls are created in code.
I have a text field with a keyboard active. The first time I load the text field and use the keyboard, everything works normally. The second time I use it, the typed text does not show in the text field. However, the text is in the text field programmatically. For example, I can use it to execute a search. When the keyboard closes, the text appears.
Some of my UITextFields have misaligned text. For example, I write "hello", and instead of displaying centered inside the field like normal, it displays shifted several pixels downward to the extent that the bottom of the text is cut off. It's almost as if another view is chopping the bottom off the text by obscuring it.
I use three20, but according to http://groups.google.com/group/three20/browse_thread/thread/d7c4bc1ee2f9590d#, Xcode is suspected of causing the problem. I seen the behavior on 2 diferent macs, one running with Snow Leopard (10.6) and the other with Leopard (10.5).
This is how the problem looks in Xcode:
It is not obvious, but there is text in that search field. Notice that the placeholder text is not show. However, if I hit Search, the code executes with the entered text.
This is how the app appears in the simulator:
I finally find the reason.
I call [textField becomeFirstResponder] in a function called from loadView. But I move it to viewDidAppear and everything work Ok...
I've seen that happen with text fields and affine transforms. If you rotate a text field using a transform, the text shows up in a seemingly random part of the superview. If you use a transform to move the text field to make room for the keyboard, you might be seperating the embedded text editor from the field itself. That would also explain why the text is in the code because the text attribute of the text field is not affected by the visual layout of the UI.
I want to create my own number pad to appear after user focus the textfield, so I have two question about it?
1.I use "Interface Builder to add a textfield in my view and select the "Number Pad" as the default pad for user to input number, so when I click the textfield, the number pad appear automaticlly, how can I stop it appear the number pad? because I want to show my number pad.
2.If I custom a view with number button inside it, how can I detect the event when I click the textfield? and whether after I detect the event I add a subview to show my custom number pad or not?
thanks
If you are creating a custom number pad (I assume this means a view with a grid of buttons), don't bother using a UITextField; there is no easy way to hide the native keyboard and, for all that trouble, there is nothing useful that the text field gives you.
I recommend creating a custom UIControl subclass. You can detect a touch inside the view and show your custom keypad that way. The documentation explains this pretty well.
I have a partial answer but not an ideal one, and I haven't tried this myself. Take a look at the documentation for the UITextFieldDelegate protocol.
You could have your controller set textField.delegate = self, then have it implement textFieldShouldBeginEditing to show your specialized keyboard somehow and then return NO so that it doesn't go into edit mode. When you tell your special keyboard to show itself, pass it a reference to the text field so it knows where to insert characters. The problem is that this probably won't show a cursor and won't let the user move the cursor to insert characters, etc.
So really this a bit ugly, but it may be sufficient. AFAIK there is no good way to do this :(