Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewController - disable selection

How can the ability to select cells in a Cocoa Touch TableView be completely disabled?

I have managed to get my code to a state where selection seems not possible, but if you hold your finger on a cell for a moment or two it will turn blue (selected) until you move off it.

How can it be completely disabled?

like image 690
Nippysaurus Avatar asked Aug 26 '10 02:08

Nippysaurus


People also ask

How do I turn off cell selection?

If you want to disable selection for just some of the cells, use: cell. userInteractionEnabled = NO; As well as preventing selection, this also stops tableView:didSelectRowAtIndexPath: being called for the cells that have it set.

How do I remove table view separator?

To hide UITableViewCell separator completely, simply set it's colour to UIColor. clearColor(). This will make the cell separator not visible.

How do you deselect a row in Swift?

deselectRow(at:animated:) Deselects a row that an index path identifies, with an option to animate the deselection.

What is UITableView in Swift?

A view that presents data using rows in a single column.


2 Answers

See the allowsSelection property of UITableView.

myTableView.allowsSelection = NO;
like image 69
imaginaryboy Avatar answered Dec 08 '22 20:12

imaginaryboy


from the apple documentation on Gesture Recognizers

Generally, a window delivers UITouch objects (packaged in UIEvent objects) to a gesture recognizer before it delivers them to the attached hit-test view. But there are some subtle detours and dead-ends in this general delivery path that depend on whether a gesture is recognized. You can alter this delivery path to suit the requirements of your application.

so... I haven't actually implemented this, but have done some reading on it... It might be a possible solution

like image 30
Aaron Saunders Avatar answered Dec 08 '22 21:12

Aaron Saunders