UITableView the cell is selected, there is a gray background matte effect by default, and the gray mask is the cell's own
Selectedbackgroundview
We can set the frame, and the background color of the Selectedbackgroundview
Selectedbackgroundview. BackgroundColor
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath { = [Uicolor redcolor]; = cell.frame;} -(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{ [ Self performselector: @selector (Unselectcell:) withobject:nil afterdelay:0.2];} -(void) Unselectcell: (ID) sender{ [_setuptableview deselectrowatindexpath:[_ Setuptableview Indexpathforselectedrow] animated:yes];}
This allows you to customize the selected effect. Problem to pull, when a cell is selected, you will find that the cell that the cells want to come to the partition line is gone (press the cell, no bounce, the mask is displayed).
This is a noticeable bug after iOS7.
Http://stackoverflow.com/questions/19212476/uitableview-separator-line-disappears-when-selecting-cells-in-ios7
This answer has been tried all over, or not.
Do it yourself, decided not to use the System Division line, add a try yourself.
Add both methods in the base class of your cell or in a custom cell
/** * Set the split line, Separatorinset may not be able to implement * resolve the split line display when the selected cell Selectedbackgroundview display * problem See:Http://stackoverflow.com/questions/19212476/uitableview-separator-line-disappears-when-selecting-cells-in-ios7* @param insets insets Description*/-(void) Setseparatorwithinset: (uiedgeinsets) insets{ for(inti = ([Self.contentView.superview.subviews Count]-1); I >=0; i--) {UIView*subview =Self.contentview.superview.subviews[i]; if([Nsstringfromclass (SubView.class) Hassuffix:@"Separatorview"]) {Subview.hidden=YES; Subview.frame= CGRectMake (Insets.left, Insets.top,self.width-insets.left-insets.right, Subview.height-insets.bottom-insets.top); UIView*separatorview = [[SubView Superview] Viewwithtag:10456]; if(!Separatorview) {Separatorview=[[UIView alloc] initWithFrame:subView.frame]; Separatorview.tag=10456; [[SubView Superview] addsubview:separatorview]; }Else{Separatorview.backgroundcolor= [SubView backgroundcolor];//[Uicolor Redcolor];Separatorview.frame =Subview.frame; } [[SubView Superview] bringsubviewtofront:separatorview]; Break; } } }
-(void) Setseparatorcolorwithcolor: (Uicolor *) sepcolor{ for(inti = ([Self.contentView.superview.subviews Count]-1); I >=0; i--) {UIView*subview =Self.contentview.superview.subviews[i]; if([Nsstringfromclass (SubView.class) Hassuffix:@"Separatorview"]) { if(sepcolor) {Subview.hidden=YES; Subview.backgroundcolor=Sepcolor; UIView*separatorview = [[SubView Superview] Viewwithtag:10456]; if(Separatorview) {Separatorview.backgroundcolor=Sepcolor; }Else{Separatorview=[[UIView alloc] initWithFrame:subView.frame]; Separatorview.tag=10456; [[SubView Superview] addsubview:separatorview]; } [[SubView Superview] bringsubviewtofront:separatorview]; } Break; } }}
One is to set the split line frame one is to set the color.
Which traverses the subview reverse of the cell. (Increase efficiency) find the split line, hide it, rewrite a view on the Superview of the split line. This solves the problem that affects the split line when using Selectedbackgroundview to select cells in the above problem.
Note: TableView uses section display as if it's OK (put the cell in sections), my Project Settings page is so no problem using Selectedbackgroundview. This problem occurs when there is only one section.
Finally, I'll answer the question on the StackOverflow.
iOS7 UITableView Split line is not displayed when using Selectedbackgroundview selected