UITableViewCell with UIButton is not scrolling - ios

I have UITableView. Each UITableViewCell content UIButton. UIButton's frame is equal to UITableViewCell's frame. But scrolling is not working when I tapped on button and scroll, only when I tapped on space between cell's scrolling is working. How can I fix this problem?

You need to disable the user interaction of your button. Then it will not take the touch event and you will be able to scroll properly.

The button is not forwarding the touch to the cell.
The easiest solution would be to give the cell the appearance of a button and use the normal delegate methods.

Related

UICollectionViewCell scrolls when UITextView is tapped, doesn't scroll back when keyboard dismissed

I have a UITextView in a UIScrollView in a UICollectionViewCell, and when I tap it, everything scrolls up for the keyboard, but it never scrolls down when I close the keyboard.
This problem only occurs when everything is inside a UICollectionViewCell
I have not added any code to cause the scrolling up, in fact the UICollectionViewCell isn't even a delegate of the UITextView
Has anyone run into this? Or does anyone know how to disable it from scrolling up altogether when the keyboard appears?
Thanks for any help...
I found the answer to this finally. I thought that because my UICollectionViewCell has a UIScrollView in it, that the content in the UIScrollView was being scrolled up. What was actually happening was the UICollectionView was actually moving the frame of the entire UICollectionViewCell up 200 pixels when the keyboard appeared, but wasn't moving it back down when the keyboard disappeared, so I just made the UICollectionViewCell a delegate of the UITextView and when it ended editing I reset the cell's origin to (0, 0)

Disabling touch interaction of Spaces between Custom table view cell

I use custom cells of subclassing UITableViewCell in a table view. And There must be space between cells. I succesfully add the space with adding a subview that I called SpaceView into the content view. But When I touched the spaceView, it is perceived as I touched the cell. And didSelectRow method called. I tried to set spaceView's UserInteractionEnabled==NO. But It doesn't work.
So my question is; Is this the right way I used to add space between cells ? Should I try to add cells for making the space ? or If its the right way, How can I prevent calling "didSelectRowAtIndexPath" method when I touched spaceView ?
like Inder said below, u can use an UIButton to solve the issue.
1) in your custom cell: at the bottom of your custom cell add a blank UIButton with the height u actually need between cells, and customize its background color according to your needs.
2) in cellforrowatindexpath: disable button of each cell. (or you can also do that in Interface Builder of previous step)
result: u have a clear disabled button that will appear as required space between cells.
Make your spaceView as UIButton (I guess it's UIView right now)
When you add UIButton that touch will be consumed by the button thus touch won't be passed to it's parent.
OR
I'm not sure if it will work or not, you can add tap gesture to your spaceView

UITableViewCell swipe to delete doesn't work when cell contains full frame button

I've put UIButton on UITableViewCell and it takes full frame of cell.
When I'm trying to swipe cell to start editing mode, button catches this swipe event as usual touch and doesn't forward it to UITableView.
Is there an easy and neat way to forward horizontal swipe on button to UITableView or UITableViewCell, not sure, who should handle this event to start editing mode.
BTW, vertical swipe is forwarded correctly to UITableView and allows to scroll it.

Make elements in UITableVew Custom cell touchable

I have a UITableView with custom cell XIB. The custom cell has two labels and one UITextView. It all works fine, however I noticed that when I press on the labels or the UITextView, nothing happens. Its only when I press an area of the cell which is not covered by the labels or the UITextView that the cell will respond.
How can I make the cell respond to anything that is touched in the cell?
Thanks, Dan.
Yeah basically I forgot to select the interaction option in Interface Builder. lol...

UITableViewCell selectedBackgroundView customization

I have a custom UITableViewCell with a custom selectedBackgroundView. Is there a delegate method when the selectedBackgroundView shows? For example, if I press one cell and keep it pressed, the cell is highlighted and the selectedBackgroundView is showing. I want to change one of the cell's subviews when this happens.
I have tried using the gesture recognizer's delegate method -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer, but this gets called too late. I want a to know the second it starts that selection animation. If this can't be done, is there a way to make the selectedBackgroundView be on top of all the cell's subviews?
Figured it out. You have to override -(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated and perform the changes there. I also tried overriding the touchesBegan event, but doing this completely removes the cell's selection (doesn't get selected anymore).

Resources