UITableView separator line disappears when selecting cells in iOS7

后端 未结 24 2149
耶瑟儿~
耶瑟儿~ 2020-12-05 04:01

In my tableView I set a separator line between cells. I am allowing selection of multiple cells. Here\'s my code for setting selected cell background color:

         


        
24条回答
  •  盖世英雄少女心
    2020-12-05 04:35

    This'll just happen if you let iOS apply its own default selected cell style. Best work around I found so far is to override the selected property implementation:

    in your cell subclass implementation:

        @synthesize selected = _selected;
    

    in the initialization method:

        // problem actually is caused when you set following 
        // to UITableViewCellSelectionStyleDefault, so:
    
        [self setSelectionStyle:UITableViewCellSelectionStyleNone]; 
    

    overriding methods:

        - (BOOL)selected 
        {
            return _selected;
        }
        - (void)setSelected:(BOOL)selected animated:(BOOL)animated 
        {
            _selected = selected
            if (selected) {
    
                // apply your own selected style
    
            }
            else {
    
                // apply your own deselected style
    
            }
        }
    

提交回复
热议问题