First, the problem description
In the study and development often encounter the following problems, UITableView UITableViewCell little or no time, but UITableView have a lot of blank line split line. Such as:
How do I get rid of UITableView extra blank line split line?
Second, the problem analysis
Method One: Hide the UITableViewCell from the split line, and then customize the split line to UITableViewCell. There are many ways to customize a split line, and you can find it yourself.
Method Two: very simple, modify the Tablefooterview. Create a UIView with a frame of Cgrectzero , and assign a value to Tablefooterview.
Second, problem solving1. Custom Split Line
Lists one of the ways to customize a split line.
Step One: Global Settings uitableviewcell system comes with a split line "hide", this "hide" simply sets the split line color to transparent. This is done to keep the custom split line frame and the system's own split line. If you don't want to, you can really hide.
1 -(void ) viewdidload 2 { // Set the style of the split line 4 self.tableViewCategory.separatorStyle = Uitableviewcellseparatorstylesingleline; 5 self.tableViewCategory.separatorColor = [ Uicolor Clearcolor]; 6 self.tableViewList.separatorStyle = Uitableviewcellseparatorstylesingleline; 7 self.tableViewList.separatorColor = [Uicolor Clearcolor]; 8 }
Step Two: in UITableViewCell
1 //self-plotting split line2- (void) DrawRect: (cgrect) Rect3 {4 //gets the split line that comes with the cell system, and gets the split line object to keep the custom split line frame and the system's own split line. If you do not want the same, you can ignore. 5UIView *separatorview = [Self Valueforkey:@"_separatorview"];6NSLog (@"%@", Nsstringfromcgrect (Separatorview.frame));7NSLog (@"%@", Nsstringfromcgrect (rect));8 [Super Drawrect:rect];9Cgcontextref context =Uigraphicsgetcurrentcontext ();Ten Cgcontextsetstrokecolorwithcolor (context, [Uicolor colorwithred:232/255.0 green:232/255.0 blue:232/255.0 Alpha : 1]. Cgcolor); One //cgcontextstrokerect (context, CGRectMake (0, Rect.size.height-1, rect.size.width, 1)); A cgcontextstrokerect (context, separatorview.frame); -}
Effect:
2. Modify tablefooterview
1 Self.tableView.tableFooterView = [[UIView alloc] Initwithframe:cgrectzero];
Effect:
iOS Learning Note 20: Remove UITableView extra blank line split line