UITextView in custom UITableViewCell not responding to didSelectRowAtIndexPath - iphone

I have a UITextView in my custom UITableViewCell and the issue is that when I tap on it it won't respond to the didSelectRowAtIndexPath or even swipe events. How can I fix this? This UITextView is not editable. The reason why I use this over a UITextField is because I want to be able to detect links easily.

I realize this is an old question, but I recently had the same issue. The fix in my case was to simply turn off "User Interaction Enabled" for the UITextView.

you need to forward the touch messages from UITableView to UITextView
UITextView inside UITableView

The first idea that came to mind...
In cellForRow set the textfield tag as the indexpath.row
Implement - (void)textViewDidBeginEditing:(UITextView *)textView
Based on this textView.tag, call the selectrow
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:textView.tag inSection:<#(NSUInteger)#>]
animated:<#(BOOL)#> scrollPosition:<#(UITableViewScrollPosition)#>]

I don't know if it's what are you looking for But in my case i had a custom cell with UIImage, and UITextView and only when I clicked on UIImageView i got didSelectRowAtIndexPath recogniser. Make sure UITextView is user interections unable like that to fix the problem

Check if your TableView Selection property is set to NO
Wrong :
tableView.allowsSelection = false
DidSelect Wont be called
It has to be:
tableView.allowsSelection = true
Also Check your Nib

Related

UiTextView in Custom UiTableViewCell does not responds to didSelectRowAtIndexPath

I have a UITextView on a custom UITableViewCell and when I click on the UITextView, it does not trigger the didSelectRowAtIndexPath, how do I change this behavior so that that delegate is called as intended?
Ive tried putting the User enabled property of UITextView to false. When doing so it responds to the didSelect. But then Im not able to select the links that are mentioned in the TextView, which essentially is the main reason why i chose to go ahead with UITextView.
Any help or pointer guys
you can't do both the things at same time.
you can use UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath] in you didselectrowatindexpath method.
you need to give appropriate tag to every text field and by using [cell viewWithTag:<#(NSInteger)#>] you can get the text-field object and link which are mentioned in it .
If your table view is custom, you can fire didSelectRowAtIndexPath event yourself when the user touch the text view.
Well I managed to work around by putting a custom UIButton on UITableCellView and firing off the required methods on UIControlEventTouchUpInside. This ate my brains for 2 days!!

UITableViewCell - Changing All Cells to BackgroundView

I would like to add a UIButton to my TableViewController that will change all the cells in a UITable to the backgroundView from the contentView.
It would have the same functionality as setting self.myTableView.editing = YES to reveal the editingAccessoryView for all the cells.
Is this possible? If so, how can this be done? Thank you for your responses!
The button toggles a flag (e.g. sets a BOOL property to YES if it is currently NO) and calls [self.myTableView reloadData].
This causes cellForRowAtIndexPath: to be called again for all the visible rows. And cellForRowAtIndexPath: examines that flag (the same BOOL property) to decide what to do about the background view.

Strange Behavior-Did select row touch not responding for UITableViewCell

I have a very strange problem,I don't know whether it is awkward to normal behavior of cells or not,it seems as if it is so!Hence I am giving it up to some one who can answer, apologize if any thing stupid in asking this question.Normally,when we touch a table view cell,what happens is it navigates to a view controller/a controller that is coded.Now what's strange here is it is not responding to selection,or touch.I have checked whether or not allows selection while editing is selected in IB or not.I have selected it,now the twist here is when I am touching a table view cell it is not responding,instead when I swipe it horizontally/when I long press the cell,it is navigating,really surprised at this strange behavior!I don't understand the reason why I need to swipe it to make selection of cell in table view work.This is also happening with button present below the table view!
I have searched for issues similar to my case,but I found just one question there it was suggested to check for this method,
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
But i haven't implemented that method at all,what I have actually is a tab bar with several items,where I have a controller called AddController,for accessing several attributes and strings etc.. declared in the controller,I am subclassing it as follows:
#interface ViewController : AddController
Now because it was specified in the question I saw,i.e. the link I gave,to check whether u are copying the same code in subclass controller page,I spoke about subclassing and what I did,hope every one understands it!
Can any one please guide me how to get out of this issue,and make table view cell respond to normal touches,any help is greatly appreciated!
Thanks all in advance :)
After doing some research I'm pretty sure that it is the UITapGestureRecognizer on the tableView caused you the problem. If you were like me having the text field in the cell and using the UITapGestureRecognizer to close the keyboard, here's my solution:
In the view that you implemented UITextFieldDelegate
(In my case I have a custom UITableViewCell called TextFieldCell),
Declare a UITapGestureRecognizer as a property:
#interface TextFieldCell : UITableViewCell <UITextFieldDelegate>
{
UITextField *theTextField;
UITapGestureRecognizer *gestureRecognizer;
}
#property (nonatomic,retain) UITextField *theTextField;
#property (nonatomic,retain) UITapGestureRecognizer *gestureRecognizer;
And initialize it in your view:
self.gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(closeKeyboard:)];
In the - (void)textFieldDidBeginEditing:(UITextField *)textField method, use superView to move up to your tableView and call addGestureRecognizer:
[self.superview.superview addGestureRecognizer:gestureRecognizer];
And in the - (void)textFieldDidEndEditing:(UITextField *)textField, just remove the gesture recognizer:
[self.superview.superview removeGestureRecognizer:gestureRecognizer];
This will totally solve the problem.
Did you use a UITapGestureRecognizer on your tableView? I had the exactly same problem as you did today, and then I figured out that it was the gesture recognizer that blurs my intention for selecting a row by tapping. When I removed it, the tableView was back to normal.
Hope this helps.
I had this same problem and solved it by ticking "Scrolling Enabled" in the table view attributes.
My table view doesn't need scrolling, so it doesn't affect the app in any other way, except now I don't get the first unresponsive tap after a swipe gesture.

UITextField in UITableViewCell

I have a standard UITableViewController. In the cellForRowAtIndexPath I add a subview to cell.contentView. This UIView itself contains a UITextField object. This object will not respond to touches. I have set the delegate to the UIView and implemented all the methods. I have also set userInteractionEnabled = YES. When I tap the UITextField nothing happens! I feel it's being absorbed by the cell. What would be the easiest, least messy fix?
Best,
Joris
EDIT: Sorry, see my answer. I solved it.
I'm an idiot. Sorry for wasting everyone's time. I hadn't properly said the UIView's frame. It of course did display the UI elements, but wouldn't respond to them.
Try just adding the textfield as a subview of the cell, this is what I have done in a couple of my apps and had no problems with it
In your tableView, try to set
allowsSelection = NO;
Try setting the editing property of the table view to YES.
Check this answer
Editing a UITextField inside a UITableViewCell fails

iPhone - Custom UITableViewCell with clickable UITextView

I created a custom UITableViewCell and placed a UITextView element on it. Now when I click on the UITextView inside the cell tableView:didSelectRowAtIndexPath: is not called (in the superview which is a UITableViewController).
Should I make the UITextView "transparent" or something? How can I do that? I get the same effect when adding a button.
Adjust the userInteractionEnabled property to NO
someTextView.userInteractionEnabled = NO;
Documentation here: http://developer.apple.com/library/ios/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/userInteractionEnabled
Similar question here: iOS: Selecting through UITextView on custom UITableViewCell