textViewDidBeginEditing: within UIWebView not being called - ios

i´ve created a subclass from UIView and put in a UIWebView. This displays a simple external website which contains just two textfields. The user can type in his email address and the verification.
I´ve already included the UIWebViewDelegate for the webViewDidFinishLoad: method. Additionally i´ve created a NSNotification for "UIKeyboardDidShowNotification".
Everything works, but when i select the second textfield, the first textfield automatically will be scrolled half out of the visible area. I´ve also included the UITextViewDelegate with - (void)textFieldDidBeginEditing:(UITextField *)textField but i get no NSLog from that delegate method.
Any help how i can get the frame of the selected textfield (within a UIWebView)?
Thanks for any hints...

I´ve read that there are no UITextField delegates when using UIWebView. So therefore no information about which textfield is currently selected, right?

Related

HKTextview emoji detection

I'm having an issue. I am using the Hakawai framework in an app so that I can have mention support (#username).
The issue I've run into is that the textfield I am using is not registering the case where there is no text and a user types an emoji into the textview. As we are using HKWTextView, I believe the textViewShouldChangeTextInRange delegate method is never called, even if implemented. The only replacement I can think to use is :
- (void)textView:(HKWTextView *)textView didChangeAttributedTextTo:(NSAttributedString *)newText
originalText:(NSAttributedString *)originalText
originalRange:(NSRange)originalRange;
in HKWTextView, but that's still not picking up on emojis being typed in when no other text has.
The functionality I would like is:
- Text view is empty
- user types in anything, emoji included
- textview width shortens, "Post" button appears.
Right now, typing emojis into the empty text view will not make the post button appear. However, it's worth mentioning that once the emojis are typed in, if there is more than one, deleting one of them WILL make the post button appear. I'm at a bit of a loss here.
I found the answer to this - It turns out that HKWTextView does some rewiring of the UITextView delegate methods that are fired. Try handling the input in the UITextView delegate method textViewDidChangeSelection. That method will be fired when an emoji is typed.

Trying to implemen custom number pad for UITextField in iOS

I am working on an app where I have a UITableView that has a UITextField in each cell. The textfield is attached to each row via a custom cell. Because there is no number only keypad for the iPad, I have to implement my own (I don't have a choice here). I have created custom buttons for this keyboard inside MainStoryboard, attached these buttons to a view that serves as a custom inputView. These buttons all call the same method which should enter the value of the label on the button, into the textfield. Unfortunately, this is not working. I am implementing the UITextFieldDelegate method:
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
NSLog(#"how about here?");
return YES;
}
which unfortunately does not get called when I place the cursor in any of the textfields, and not when I press any of the keys on the keypad, since I don't see any output on my xcode screen.
I attach the custom keypad to the inputView attribute of each textfield inside my "cellForRowAtIndexPath" method as follows:
_cell.textField.inputView = _inputView;
Can anyone see what I'm doing wrong? I figure implementing the UITextFieldDelegate would be the way to go to accomplish this (which to me appears to be very straight forward), but unfortunately I'm struggling with this. I have also included a screenshot if it helps.
Thanks in advance to all who reply.
Make
textField.delegate = self
or
_cell.textField.delegate = self;
Hope this works !!!

Detecting when a user is beginning to edit an UITextView

I am wondering if it is possible to detect if a user is beginning to edit a text view (so that I can make certain adjustments to the view). Would I have to detect for the keyboard instead?
Yes it is possible using UITextView's delegate. You can see documentation of the UITextViewDelegate protocol here.
There is a nice tutorial found here that will show you how to detect these interactions using the UITextViewDelegate protocol.
Take a look at UITextViewDelegate. Implement textView:shouldChangeTextInRange:replacementText: if you want to react while the user is typing or textViewDidChange: otherwise.
Edit: If you are only interested when the text fields becomes the first responder (i.e. the user sets the focus), use textViewDidBeginEditing.
Assign your textView's delegate in your xib file (or programmatically)
Use one of these:
- (BOOL)textViewDidBeginEditing:(UITextView *)textView {
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {

resignfirstresponder on a UITextView inside a UITableViewCell

I am hoping if someone can help me resolve an IOS/XCode question.
I need to have a UITextView created inside a UITableViewCell, this UITextView has responds to a user click, upon which a UIPopoverController will be displayed so that a sub-UITableView is displayed (inside the UIPopoverController) allowing a user to select from a list of choices (lines of text). After the user select the choice (one of the line of text), that line of text will then be displayed inside the said UITextView. First problem I am having is that when the user click on the UITextView the keyboard gets displayed instead of the UIPopoverController. How do I go about disabling ie. calling resignFirstResponder so that instead of the keyboard displaying, I get the UIPopoverController coming up instead. Would someone be kind enough to share similar codes? or point me to some sample of how this can be done? Thanks so much in advance.
You can use following delegate method to detect when textView is tapped and show your popOverController accordingly, return 'NO' in the delegate method so that no keyboard will appear...
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
// code to show popOverController
return NO;
}

UITextField is not responding

I'm experiencing some problems with UITextField inside a UITableViewCell.
Things are working well until I open the iOS media player, watch a short movie and going back to my view.
Then, I'm trying to click on the UITextField, but nothing happens and it does not responds to my clicks.
In the same screen (it's a UITableView), I have a switch button (in another row), which is working fine after switching views.
My view is implementing the UITextFieldDelegate protocol and textFieldShouldReturn in particular.
My implementation of textFieldShouldReturn is a simple call to : [textField resingFirstResponder]
I'll appriciate any thoughts or ideas why it happens and how to solve it.
Thanks!
koby
I had this same problem, what fixed it for me was to make sure to return the correct height for the table view cell. Check your heightForRowAtIndexPath function - even though you can see all the objects in your cell they may be outside of a clickable/tappable area.

Resources