How do you launch a UITextView (iPhone) in edit mode? - iphone

I'm working on an iPhone app with only one view, a UITextView, and I want it to launch all ready for typing (with the keyboard activated) but by default it requires the user to first tap the view before the keyboard appears. I've seen this done in other applications but haven't been able to figure it out. Thanks.

you need to use the -becomeFirstResponder method on your field:
[myTextField becomeFirstResponder];
This will pop the keyboard up. To hide the keyboard, use -resignFirstResponder.

Related

UIMenuController not showing UIPasteBoard is cleared iPhone app?

Am working in message based iPhone application. In my application looking like iMessage native iOS app. I made Bubbles with used UIImageView and UILabel. I made UILabel as clickable and showing Copy option. It is working fine when the message input UITextView is not in active.
1. I can show the "Copy" option when we clicking UILabel and the UITextView is not becomeFirstResponder.
2. When the user clicking the MessageTextView (UITextView) from the bottom of the screen the UITextView becoming first responder and keyboard is showing now. In this scenario if the user clicking the messabe bubble (UILabel) the UIMenuItem showing "Paste" on the bubble instead of "Copy".
3. If i click "Paste" from the bubble UIMenuItem already copied text will be pasting in UITextView. So the control fully in UITextView UIMenuController not activated in UILabel. So i cleared the text from UIPateBoard when the user clicking the Bubble (UILabel).
4. Now the UIMenuController not showing up even [self becomeFirstResponder]; not becoming in UILabel class.
The reason is when the UITextView is in becomeFirstResponder the control fully in that. not coming to UILabel. Could you please help me on this.
How to show UIMenuItem "Copy" when the user clicking UILabel if the keyboard is in visible the control is in UITextView? Could you please help me on this. I spent two days in this issue. Thanks in advance.
May be I am wrong.CONSIDER THIS ANSWER AS A COMMENT.
I tried to achieve like what you are trying to do. Thats not working too. I figured out I cannot make access the two views at the same time. Especially when I have any view becomeFirstResponder and you cannot access menu items of other view.
But if you try like this,you may succeed in your code.
1) In the touchesBegan: method, find the user touching inside your UILabel.
2) If that happens, then show a custom view with buttons like copy,paste and select like that.

how to popup default iphone keyboard on a button click

Hi
When we click on a UITextField or UITextView, a default keyboard pops up from the bottom of iphone screen. I want iphone keyboard to appear on a button click, and then handle the keys as typed on keyboard... How can i do that?
Add touchupinside event on button and call becomeFirstResponder method for textview or textfield it will call pop up keyboard.
see the following code-
-(IBAction)buttonClicktoModalView:(id)sender{
[textView becomeFirstResponder];
}
I was searching my problem, and came across the following stackoverflow link which answers my question
How to pull up a UIKeyboard without a UITextField or UITextView?
Thank you
Pls go through this
iphone keyboard without textview
Hope this helps

Disable the Go button in the Keyboard for a UITextfield in iphone app

My app has a screen where keyboard is always visible. The main element of the screen is a UITextfield. For easy data entering, keyboard is always made visible. When the user finishes entering data and hits Go, the app performs a 4,5 seconds action which is done in the background thread in order to show UIActivityIndicatorView.
My problem is that the Go button on the keyboard still shows as enabled since the logic is performed in the background. The user could potentially hit the Go again causing it to run again.
I am not able to set editable/userinteraction properties to No because then the keyboard disappears. Is there anyway just to disable the Go button or freeze the keyboard until the background thread returns?
You clearly already have a UITextFieldDelegate set up to handle:
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField;
Otherwise, you would not be able to perform accordingly already. Just return NO from that function if the background process is running and the keyboard should not close. Example:
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (alreadyPressedGo)
return NO;
...
}
However, this will not "disable" the Go button, simply disable its functionality.
I've not tried it (not at an OS X box at the moment otherwise I'd give it a go), but I'm wondering if you couldn't effectively disable it by placing a touch receiving UIImageView or similar on top of it. (You could even set the opacity of the UIImageView accordingly to achieve a greyed out look.)
This is combination with the disabling the operation of the button as #Skyler illustrated should be ideal.

UITextView with "Done" button *and* "Return" key?

I use a UITextView for multiline text entry in my iPhone app, and I have set the "Return" key to display "Done." I've also set up the return key to disable first responder status, so that hitting "done" actually exits the UITextView. However, I also want to enable users to be able to enter multiline text into the UITextView, i.e. to be able to use the "Return" key. Is there any way to make this work on the iPhone/iPad's UI?
I've been struggling with this issue for 5 years waiting for apple to wake up and create some sort of solution for the textfield multiline responding to done button until I decided to create one myself.
there you go:UITextField multiline with hide keyboard option
It'll be time consuming but you could create your own keyboard with both these keys (this can be done by specifiying the Input View for the UITextView ).
Another alternative could be having a button that sits just above the keyboard that would dismiss the keyboard. You can use the UITextView's Input Accessory View which allows you to create a view that sits on top of the keyboard. See here for more information (I'm aware this document is for iPad but it works for all iOS devices - also just to note, both these require iOS 3.2 or greater).
This should only need to be done on the iphone because the iPad keyboard already comes with a dismiss keyboard button as well as a return button.

TextField with Keyboard in cocos2d !

I am trying to develop a iphone app by using cocos2d. I create a alert view with a text field. when I touch the text field then comes the keyboard. But I want that when the alert is open, in the same time textfield will be selected and keyboard comes(without any touch). how can it posible ? sorry for my bad English.
[myTextField becomeFirstResponder] will probably do what you want.
That would be a little tricky to do. The controls in iPhone use the concept of "first responders" Any events will be handled by the first responder in the controller. Now, when an alert view is displayed, it becomes the first responder so it can respond to button clicks. When a text field is selected by the user, the keyboard gets the control. So I guess what you want to achieve can be done by making the text field the first responder after showing the alert ([txtField becomeFirstResponder])
But I have no idea how the alert view's responses will be handled then. You won't be able to click the OK button on the alert view till the keyboard is dismissed and you resign the first responder of the text field. ([txtField resignFirstResponder]) (This is just a guess, you will have to check the final behavior)
[myTextField becomeFirstResponder] works -- I tested it.