Limit the cell selection area in uitable view - ios

I have a custom cell in table view, which allows multiple selection. Can i limit the cell selection area of a custom cell. Can i enable selection area to only the left side of the cell not the entire cell.
Please share your thoughts.

In your UITableViewCell subclass override pointInside:withEvent: method and return YES only for the points inside the area you want.

Yes, the way you want can be implemented, You make a button on left side of your cell. So Whenever you click on button your selected are will be enabled.
You do not need to implement any logic in UITableView DidSelectRowForIndexPath.
Need to manage in your button.

You can add a UIButton on the left side of your cell, by this way you can easily handle the selection of UIButton by using its tag value.

In the custom tableView Cell. The are which you want to be non clickable add a button to that area and if a tap is registered in the button the didselectitem at indexPath would not be called I have done a similar implementation myself.
My TableView Implementation

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.

Can I make only a certain portion of a tableview clickable?

I'm trying to add a like button in a tableview but If I click anywhere in the tableview, it immediately goes to the detailsVC. I want to make it so when you click that like button, only that is selected. Is there a way to make it so only the top half of the tableview can be selectable or have interaction enabled, and put the button below? Or is there another way to do this. Is there a workaround or a method I am missing. Thanks
Are you sure the UIButton is added correctly to table view cell's .contentView?
Can you see it? If so it will intercept the touch events and tableview's delegate didSelectRowAtIndexPath won't get called (even if there's no handling connected to the button). If you want make the button occupy specific area of the cell you can either:
Design your cell in Interface Builder and make it a part of Storyboard/Xib
Do autolayout of the cell programmatically
Override cell's layoutSubviews and manually setup the frames

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

Making UITableView with delete buttons visible for all cells

Normally one can create a UITableView with cells that allow the user to reveal the red "Delete" button on the right side of the cell by swiping that cell or by tapping a knob visible on the left side of the cell.
However, I would like to create a UITableView which has all cells with visible "Delete" button by default (no swiping / tapping knob necessary). Is it possible to do utilizing the standard Cocoa Touch methods?
(I know I can define my own button in a custom UITableViewCell, but I'd rather use a standard method if possible...)
Call [tableView setEditing:YES animated:NO] in your view controller's -viewDidLoad implementation.
Well.. NO. Actually the red minus on the left side is the constant-visible solution in Cocoa. I don't believe you get the right delete button without ugly hacking of the tableView.
So probably you have to make a custom solution. But you need no subclassing here. You can just use a regular UITableViewCell and set a UIButton as the accessoryView.

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