Make elements in UITableVew Custom cell touchable - ios

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

Related

Change a label inside a UICollectionView Cell by pressing it

can anyone point me in the right direction of trying to edit a UiCollectionView cell by pressing on it? I have 3 labels inside a XIB, and that is presented in the UICollectionView. I would like to have the user be able to edit it when they press on a certain cell. Maybe even pop up like below.
Thanks all
You should probably use a UITextField instead of a UILabel to enable user interaction. Then link that UITextField to your custom UICollectionViewCell class.

Tableview cell only segues when I click where there are no elements Swift

So, I have a custom cell with 5 components on it. Two labels, two buttons, and a text view. I want to be able to segue from this cell to another screen. The segue has been set up, but when testing, I am only able to segue if you click on the cell in a place that isn't covered by an element. Since the text view is most of the cell, it is extremely hard to segue. How can I have it so if I click anywhere on the cell (besides the two buttons of course) it will segue?
You need to set the userInteractionEnabled property of your labels to false.
Best do this in Interface Builder.
This will prevent the label from "stealing" the taps from your cell.

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

Strange behaviour of UItextView inside Tableview cell

I have a UItextView inside a UITableViewCell. When I select some text inside the textview, I have a strange animation: the cell or the textview (I don't know wich scrollview is really moving, may be both) start scrolling up and down maybe because both scrollviews (Tableviewcontroller's scrollview or UItextView's scroll view ) want to focus the selected text for their own in different ways. I've tried anything but this bad animation is still here.
The Tableviewcontroller and the textfield was made with storyboard.
ps: sorry for bad english
Use
[tableView setScrollEnabled:NO];
when the textView is focused.
if you want to show a static text just use the uilabel, which is enough.
but if you want to show and let the user edit the textview, you may allow to edit it while the tableview is in edit mode.

how to expand and collapse the UItable view cell on button click

Has anyone seen a script like this or would be willing to help out with one?
Collapse/Expand Button
The uitableview cell to be expanded partially open (giving a preview in essence)
After the button is pressed then the cell of table would expand to show the entire contents (with a nice fade effect). If you chose to collapse the cell then it would return to the original offset (preview) height.
Has anyone seen anything like this? I've found a plethora of these scripts that fully expand or collapse, but not like this
Thank you for any help!!
you have to make custom cell class. While creating cell give the height of the cell as maximum you want (i.e when it expands) and when creating the custom cell drag a UIView and put all the contents in this view and hides this view. Then when button is being Tapped just you have to make it unhidden.

Resources