The reuse mechanism of ios UItableView and UITableViewHeaderFooterView grouping headers, which is a simple and affically transformed CGAffineTransform

Source: Internet
Author: User

The reuse mechanism of ios UItableView and UITableViewHeaderFooterView grouping headers, which is a simple and affically transformed CGAffineTransform

How to Set a section of the same height, including the first column (TIPS, though easy but easy to ignore)

* Step 1: Set the tail end to 0 in viewdidload, and table. sectionFooterHeight = 0; (proxy method)-(CGFloat) tableView :( UITableView *) tableView heightForFooterInSection :( NSInteger) section {

Return 0;

} You can also set the tail height, but it does not work after setting.

Step 2: Call the tableView proxy method-(CGFloat) tableView :( UITableView *) tableView heightForHeaderInSection :( NSInteger) section {

Return 30;

} Set the header height to 30;

Running result

 

Reuse of custom group headers (similar to cell)

If the custom group Header

To optimize the memory, you can use a cell-like reuse mechanism.

 

# Pragma mark-custom group Header

-(UIView *) tableView :( UITableView *) tableView viewForHeaderInSection :( NSInteger) section {

Static NSString * identy = @ "headFoot ";

 

UITableViewHeaderFooterView * hf = [tableView dequeueReusableHeaderFooterViewWithIdentifier: identy];

If (! Hf ){

NSLog (@ "% li", section );

Hf = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier: identy];

UIView * view = [[UIView alloc] initWithFrame: CGRectMake (0, 0, self. view. frame. size. width, 44)];

View. backgroundColor = [UIColor redColor];

[Hf addSubview: view]; (if this comment: view is not added)

}

// Hf. contentView. backgroundColor = [UIColor purpleColor]; (remove this line comment: You can set hf. ContentView background color). If this line and the previous line are not commented, red is displayed.

Return hf;

}

 

Affine Transformation

-(Void) clickAction {

// Affine Transformation

// [UIView animateWithDuration: 0.5 animations: ^ {

//// Run once

/// Self. rectView. transform = CGAffineTransformMakeTranslation (100,100 );

/// Continue execution based on self. rectView. transform

//// Self. rectView. transform = CGAffineTransformTranslate (self. rectView. transform, 100,100 );

//}];

//

/// Affine ratio

// [UIView animateWithDuration: 0.5 animations: ^ {

//// Run once

// Self. rectView. transform = CGAffineTransformMakeScale (5, 0.5 );

/// Continue execution based on self. rectView. transform

/// Self. rectView. transform = CGAffineTransformScale (self. rectView. transform, 2, 2 );

// Self. rectView. transform = CGAffineTransformMakeTranslation (100,100 );

//

//}];

 

// Affine Rotation

[UIView animateWithDuration: 0.5 animations: ^ {

// 100 degrees

CGFloat degree100 = 100/180. 0 * M_PI;

CGFloat degree45 = M_PI_4;

// Execute once

// Self. rectView. transform = CGAffineTransformMakeRotation (M_PI_4 );

// Continue execution based on self. rectView. transform

Self. rectView. transform = CGAffineTransformRotate (self. rectView. transform, degree100 );

 

 

}];

 

}

 

Ios UItableView and UITableViewHeaderFooterView group headers can be reused. They can be easily converted to CGAffineTransformios UItableView and UITableViewHeaderFooterView group headers. They can be easily converted to CGAffineTransformios UItableView and grouping headers, simple ing of CGAffineTransform

Related Article

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.