text field need to long press to get touch down action - iphone

initially i crate 2 textfields in main view.
And i write IBAction to them and give touch down in interface builder.
But unfortunately i need to place scroll view in view and place these two text fields on scrollview.
in the IBAction i am calling action sheet. before adding scroll view it works fine but after adding scroll view need to long press other wise keypad will raise instead of Action sheet
what the wrong can any one pls help me.
Thank u in advance.

Is it possible to forward the touch the the scroll view? Not sure if it is but just an idea?

Hey try this UITextFieldDelegate method
This will not raise the keypad
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return NO;
}
Do let me know if ths works

Related

iPhone app: UITableViewController with UITextView in a cell, can't get rid of keyboard

I know this question has been asked before but I couldn't find an answer that applied to my problem.
I've got a UITableViewController that has a third row that is filled with a UITextView.
I'm quite happy with the way it looks and the way text is typed into it.
However I'm unable to find a way of getting rid of the keyboard once the user is done entering text. I'd like to be able to use the return button for actual \n in the text.
I've gotten this far that pressing the upper two rows will make the textView te resignFirstTransponder but is there a way to catch a tap on the greyish background?
This is all in a UITableViewController loaded from a nib file.
Btw, I'm quite new to iOS programming so the more elaborate your answer the better :)
Thanks!
A pattern many apps follow is to show a horizontal bar with buttons on it just above the keyboard. It can contain a done button clicking on which you can hide the keyboard. And of course you will have to create that horizontal view yourself.
Another way would be to enable a touch recognizer elsewhere, and on a tap outside hide the keyboard
One alternative would be to add a toolbar to the keyboard with something like a "done" button that will dismiss it. You can find some sample code about that here. One second approach would be to dismiss the keyboard when the user selects a different cell or even when the tableView scrolls. In order to do that, you can add relevant code in -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath or in -(void)scrollViewDidScroll:(UIScrollView *)scrollView respectively.
This can get a little tricky if your new at iOS. The way I handle a UITextView in a UITableViewCell is I make a custom UITableViewCell subclass with an outlet for the UITextView.
Then set your cell in interface builder to be of that subclass. In the CellForRowAtIndexPath:
set the delegate to self. Then in the DidSelectRowAtIndexPath you call the delegate for the TextView based on the indexPath, this way the keyBoard will dismiss for the correct row if you touch the background. If you want it to dismiss when the user touches any cell just call the delegate without specifying the indexPath. The Delegate is TextViewShouldEndEditing:.Ill post some code if you want.

iOS 5: Hide keyboard in UITableViewController with static cells and textfields

I'm developing an app that has an UITableViewController with static cells. Those static cells are custom ones and have UITextFields within them. If the user touches one of those textfields, the keyboard pops up. So, after that, what I need to do is to be able to dismiss the keyboard by touching anything on the background. By anything I mean the table view background, its cells and the content of those cells (like the text fields for example).
I used to do this by placing a View in the front of all my other subviews and capture the Touch Inside Up event to dismiss the keyboard. Unfortunately, I can't do this this time because I'm using a UITableViewController and I can't switch it back to an UIViewController because I've already done a lot of work with those static cells.
-(void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event{
[yourTextField resignFirstResponder];
}
Try that.
EDIT
Hi,
I've got your answer :
-(BOOL)isFirstResponder
When you enter something in a text field, it becomes first responder and the keyboard appears. You know that the keyboard is active if [textField isFirstReponder] returns YES.
You may also see that link.may be it will help you.
how to hide the keyboard when empty area is touched on iphone
Well, I found the answer myself. What I need to do was just place programatically an UIView in the foreground and do as I said in the original post. I couldn't do this before because I was trying to achieve that from the Interface Builder.

How to display a text field hidden by virtual keyboard?

I've layed out a view with some labels, a button and especially a text field in the bottom of this view. The issue is when the text field gets the focus, the iphone virtual keyboard hides the text field, so we can't see what we're typing (and I can't move the text field to another part without breaking this layout)...Any idea on how to fix this issue ?
Thx for helping,
Stephane
There is a method of textFieldDelegate calld
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
When this method gets called you can change frame property of you UIView and shift it upward.
Same way when textFieldShouldEndEditing gets called you can shift view down again.
Moreover, listing to notification UIKeyboardWillShowNotification and UIKeyboardWillHideNotification can also be useful to trigger view shifing.
If you do not know how to slide view see this.
http://iosdevelopertips.com/user-interface/sliding-views-on-and-off-screen-reader-contributions.html

How to disable the keypad on user tap?

I have a custom view which contains UITextField's.
When user clicks on the text field, numeric KeyPad pops up.
But I need the KeyPad to disappear when "user" clicks anywhere else outside the textField's in the view....
Can anyone help me out...
Thanks in advance.
You could overlay the rest of the view with a transparent view. If a user touches that, you just call resignFirstResponder and hide the transparent view.
got to interface builder and change the class property of the view from uiview to uicontrol and then make a method which includes [object resign firstresponder] .now connect that method to the the view.
like
-(ibaction)remove:(id)sender{
testfield resigh firstresponder;
}

UITextField focus

How can I programmatically assign focus to a specific UITextField in a view? I have several fields and on view display, I'd like to put the cursor on a specific field, not the first one at top.
Try doing this in viewWillAppear:
[desiredField becomeFirstResponder];
By making the field the first responder, it have focus and the keyboard will be displayed.
Set the first responder for your view to be the text field. This can be done in IB.
In swift:
desiredField.becomeFirstResponder()