UITableViewCell didSelectRowAt: not getting called when press on UIButton area in cell - ios

I have added UIButton(for some functionality requirement in project.) with checkbox image. Checkbox image select and unselect working proper on UITableViewCell tap but if I tap cell on checkbox button area button image isn't changing. I mean didSelectRowAt method isn't calling.

I found solution. I have checked that UIButton's UserInteraction ignores UITableViewCell's tap.
So I have just added below line in my code. And cell tap working good.
cell.btnCheck.isUserInteractionEnabled = false

Related

UITapGestureRecognizer on UIImageView in UITableViewCell

I have designed a UITableViewCell in a .xib. The cell contains an UIImageView that only partially covers the cell. The behavior I am seeking is, if the user taps on the UIImageView, the UIImageView's UITapGestureRecognizer's selector gets triggered, and the UITableViewCell does not trigger didSelectRowAtIndexPath. If the user taps on the UITableViewCell but not the UIImageView, then I want the opposite behavior. Right know what I'm getting is, when the user taps on the UIImageView, both the UITapGestureRecognizer's selector and didSelectRowAtIndexPath get triggered. And when the user taps on just the UITableViewCell, everything works fine. How can I get the desired behavior? I have tried messing around with cancelsTouchesInView among other things.
You don't need to use gesture recognizer to the cell, instead allow userInteractionEnabled set to true for the imageView and add target to the imageView. Refer to this code:
yourImageView.userInteractionEnabled = true
let tapGesture = UITapGestureRecognizer(target: self, action: "imageTapped")
yourImageView.addGestureRecognizer(tapGesture)

iOS - UICollectionView in UITableViewCell, problems when handling touch

I have a UICollectionView in every UITableViewCell of my UITableView.
The program should perform a segue there is a click on the UITableViewCell but the cell is clickable just out of the UICollectionView.
It is clickable just in the red portions.
Do you have any ideas?
You need to disable user interaction in each collection view:
In your storyboard uncheck here:
Or in your cellForRowAtIndexPath:
cell.collectionView.userInteractionEnabled = NO;

How to hide the particulars uitableViewCell webview in when i click on that particuar cells button uitableview?

In tableviewcells i have a buttons and webViews, with some array count.so when i tap on particular tableViewcells button action. i have to hide that particular tables cells webview?
You can do it like this, In UIButton action, you will get cell index if you've given tag to your button, using that tag, you can make cell object with NSIndexPath for the cell you've tapped, hide UIWebView subviews within that cell, you may need to set its height base on some condition which you've made in heightForRowAtIndexPath of UITableView. Another way to get the cell is, [button superview]; here you'll get containerview for particular cell, and apply the same logic, this would only work if you've added button and webview in contentview.
[cell.webView setUserInteractionEnabled:NO];
Make the webView can't get the user touch focus, so that the cell will get the user interaction : )

Strange behaviour of Subclassed UITableViewCell when selected

I have a subclass of UITableViewCell, which has a number of UILabels, a UIImageView and a UIView in it.
I have the cell set to highlight blue when it is selected. The strange behaviour that I am observing is the UIView that I have added as a property of the UITableViewCell subclass disappears when the cell is selected, and returns when the cell is deselected. This UIView is just an empty view with a background color, so it is possible that the background color is being set to clear when the table view cell is selected. None of the other elements are effected.
Does anyone have an idea what is happening here, and how to fix it?

Simulate didSelectRowAtIndexPath with a UIButton in a customized UITableViewCell

I have a UIButton in a customized UITableViewCell, which subclassing UITableViewCell.
The UIButton is IBOutlet-ed in IB, and IBAction-ed to a function:
- (IBAction)clickRead:(id)sender;
Now, when I click on the button, the button has no response, since the function has nothing inside. What should I write in the function so that the UIButton can simulate tableView's didSelectRowAtIndexPath function ( i.e. select the table cell ) ?
This answer might help: hitting a next button for a UITableViewcell
You can call UITableView selectRowAtIndexPath:animated:scrollPosition: to visually select the row, but you will still have to manage any events for yourself: loading another view, calling didSelectRowAtIndexPath:, storyboard segues, etc.

Resources