UiTextView in Custom UiTableViewCell does not responds to didSelectRowAtIndexPath - iphone

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!!

Related

Expanding UITableViewCell on Tap?

I need to expand a UITableView cell when I tap it (animate it as well). However I don't know the cell which is being tapped and I have seen the answer here: Can you animate a height change on a UITableViewCell when selected?
It seems to be a very popular answer, not just in the question. However, I need to get the cell, so how in the heightForRowAtIndexPath method can I get the cell?
Because I have tried this:
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
However using this in the heightForRowAtIndexPath method crashes the app as the first time it runs (when the view loads) it gets caught in an infinite loop I think.
Anyway if I was to take this approach how would you suggest i get around this issue? I need to access the cell. Or how else would you expand your tableview cell (animated)?
Carry on adjusting the height as you are.
I would suggest trying to get as much as you can from autoresizing masks as they have worked well for me in the past.
If you need finer grained control you can create a subclass and override the setFrame: method to find out when the frame is changing size and then set up animations appropriately there.

Live resizing of UITableViewCell without using reloadData?

First of all, forgive me if the answer is already out there (I honestly have been working and searching for about two weeks).
And now, the situation:
I have a UITextView as a subview of a UITableViewCell in a UITableView. The UITextView is the first responder (while user is typing).
I have it set up (through delegate protocol methods) so that after each typed character, the cell's rowHeight is recalculated (correctly and in the tableViews delegate protocol for rowHeight). So far everything is fine.
Then, I want that cell to be reloaded (or refreshed, whatever the term may be) without resigning its subview, UITextView, as first responder.
A non-satisfactory solution around the problem:
I am able to use [tableView reloadData] and then [textView becomeFirstResponder] to simulate this (so that user doesn't even notice that the textView was reloaded) and the rowHeight is perfect, but this has been causing me a lot of problems (especially with making sure that the cursor does not jump to the end every time the user types a character and with autocorrect forcefully enforcing its suggestions due to textView resigning).
Is there a way to redraw or resize a UITableViewCell (to dynamically change its rowHeight) without causing any of its subviews to resign as first responder?
Using tableView's [tableView beginUpdates] and [tableView endUpdates] will solve this issue. See this answer for more information.

iPhone - changing contents of a UITableViewCell inside a navigationController

I have a UITableView with some cells in it that have people's names. When the user clicks on a cell, the Navigation Controller pushes a new view onto the stack that shows detailed info for that person. When the user is done and clicks the button to return to the previous view, the tableview is again shown. The problem is that I want to edit the cell text (or just mark the cell in some way) to show that the user has clicked on that cell. In my cellForRowAtIndexPath: method I have set up code that should change the text of the cell after a user clicks on that cell. I set up break points and it IS entering cellForRowAtIndexPath: when the detail view is popped and the tableview is again shown. It's entering the segment of code in cellForRowAtIndexPath: that should change the text, but when it comes up on screen, the text has not been changed. Does anyone have any ideas as to what is going on? Thanks.
EDIT: I figured it out. I just needed to call [tableView reloadData]; instead of calling the cellForRowAtIndexPath method. Not sure why that works differently, but it fixed it.
I guess I'll help you out. You don't need to credit me with the answer though.
cellForRowAtIndexPath:
that method is called within the framework when a cell is being refreshed from the queue or when it needs to be created. You should not call this method.
[tableView reloadData];
that method is basically a refresh on all of the visible cells show in the UITableView. This is the method you should call if you change information in your data source or you need to (force) update the appearance of your cells.
It's Good You Have Reload Table And Changed The Text But If YouJustIndicate NAd Don't Want To Change The Text The nYou Can Use elow Given Text ....
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
It Will Check Mark Particuler Cell Which You Click/Visited......
Hope You Like This Solution.....

UITextView in custom UITableViewCell not responding to didSelectRowAtIndexPath

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

Change properties of UILabel in a TableViewCell

I have a tableView that's loosely based on the DetailViewController in ye olde SQLiteBooks. It's created programatically. Each cell displays a single value that when clicked displays a generic editingController that allows the user to edit that value. Pretty standard Cocoa-touch stuff...
Except...I also have a segmented control in the header of said tableView that depending on it's setting needs to change an attribute (textColor) on a UILabel in ONE of the 8± tableViewCells in the table. I have no IBOutlets for this tableView because I created it entirely in code. So, what do I need to do in my (void)segmentAction:(id)sender method (triggered when segmentedControl changes state) to allow me to access & change this value and display it to the user? When the table was built (cellForRowAtIndexPath) every UILabel was called "value" and then added: [cell.contentView addSubview:value].
I've tried setting a property of the viewController itself that is then checked during cellForRowAtIndexPath and does the textColor business there...and then adding [self.tableView setNeedsDisplay] to my segmentAction: method but it doesn't seem to work?!?
Any ideas?
If you know the indexpath of the cell you want to modify, you can call cellForRowAtIndexPath: to retrieve the UITableViewCell. Once you have that, you can get the UILabel from it. If you set the UILabel's tag to some useful value when create it, you can then retrieve it from the UITableViewCell via viewWithTag:.
In the class that implements cellForRowAtIndexPath you could also store a reference to the UILabel that you want when you build the relevant cell.
This would then mean you could alter the label and mark it to be repainted.
Alternately you could hold a local BOOL to show that the cell should be drawn differently - and then use this this in the cellForRowAtIndexPath: to draw it with a background.
You might find this easier with the 3.0 textLabel object in a UITableViewCell