Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

a problem when disable Show selection on touch of UITableview?

I use IB and uncheck the 'Show selection on touch' but it still show blue highlight on cell that is selected. Is this a bug with apple or I am getting something wrong.

like image 697
RAGOpoR Avatar asked Jan 27 '10 04:01

RAGOpoR


People also ask

How do I turn off cell selection?

You need to set the selectionStyle property on the cell: cell. selectionStyle = UITableViewCellSelectionStyle. None in Swift, or cell.

What is UITableView in Swift?

A view that presents data using rows in a single column. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.1+ tvOS 9.0+


1 Answers

This is probably a bug in IB as you see in Documentation that table view does not have any property for the shows Selection on touch. It is the property of tableview cell rather. So the checkbox should not be present in the IB. Probably you can file a bug with apple and see what they say about it.

For getting the effect you should do it like:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

            cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
                [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
            }
    }

Hope this helps.

like image 128
Madhup Singh Yadav Avatar answered Nov 08 '22 17:11

Madhup Singh Yadav