Comparison of Uitableviewstyleplain and Uitableviewstylegroup styles

Source: Internet
Author: User

First, Uitableviewstyleplain

1. Multi-period head stop (self-effect)

2. No intermediate spacing and head spacing (to be rewritten UITableViewCell \uitableviewheaderfooterview inside the Setframe method)

Extend: Leave the segment head without stopping (to remove the sticky effect)

-(void) Scrollviewdidscroll: (Uiscrollview *) ScrollView {

CGFloat sectionheaderheight = 30;

if (scrollview.contentoffset.y<=sectionheaderheight&&scrollview.contentoffset.y>=0) {

Scrollview.contentinset = Uiedgeinsetsmake (-scrollview.contentoffset.y, 0, 0, 0);

} else if (scrollview.contentoffset.y>=sectionheaderheight) {

Scrollview.contentinset = Uiedgeinsetsmake (-sectionheaderheight, 0, 0, 0);

}

}

Second, Uitableviewstylegroup

Note: Remove the head and middle interval

The right way to understand

1. Set the height of the header is a special small value (can not be zero zero if the Apple will take the default value will not eliminate the head spacing)

UIView *view = [[UIView alloc]initwithframe:cgrectmake (0, 0, self.view.frame.size.width, 0.001)];
View.backgroundcolor = [Uicolor Redcolor];
Self.tableView.tableHeaderView = view;

2. Write Agent method (the middle of the white is actually the height of the end of the role of the agent set the end of the height of the return value can not be 0)

-(CGFloat) TableView: (UITableView *) TableView heightforfooterinsection: (nsinteger) Section
{
return 0.01f;
}

This effect can also be achieved by special processing methods

1. Self.tableView.contentInset = Uiedgeinsetsmake (-44, 0, 0, 0);

2. Rewrite the Uitableviewheaderfooterview

-(void) Setframe: (CGRect) frame{
frame.size.height+=10;
[Super Setframe:frame];

}

Uitableviewstyleplain vs. Uitableviewstylegroup styles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.