8

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?

3 Answers 3

23

See the allowsSelection property of UITableView.

myTableView.allowsSelection = NO;
Sign up to request clarification or add additional context in comments.

1 Comment

This was exactly what I was looking for that disabled selection of the cell but still keeps the delete option available
1

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

Comments

0
NSData *archivedView = [NSKeyedArchiver archivedDataWithRootObject:cell.backgroundView];
cell.selectedBackgroundView = [NSKeyedUnarchiver unarchiveObjectWithData:archivedView];

you can do this by configuring the cell

1 Comment

To improve the quality of your post, please include how/why this code will solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.