TableView has three sections, each with a header. At the same time, EGOTableViewPullRefresh refreshes data, tableviewsection

Source: Internet
Author: User

TableView has three sections, each with a header. At the same time, EGOTableViewPullRefresh refreshes data, tableviewsection

 

:

 

 

 

Code:

 

. H

 

#import <UIKit/UIKit.h>#import "EGORefreshTableHeaderView.h"@interface RootViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate,EGORefreshTableHeaderDelegate>{    UITableView *_tableView;    EGORefreshTableHeaderView *refreshView;    BOOL isloading;}@end

 

. M

 

-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // update the background image [self initBackGroundView] ;}# pragma-mark-functions-(void) initBackGroundView {// tableView _ tableView = [[UITableView alloc] initWithFrame: CGRectMake (0,100,320,400) style: UITableViewStylePlain]; _ tableView. delegate = self; _ tableView. dataSource = self; [self. view addSubview: _ tableView]; _ tableView. showsVerticalScrollIndicator = NO; [_ tableView reloadData]; // refresh refreshView from the drop-down list = [[EGORefreshTableHeaderView alloc] initWithFrame: CGRectMake (0,-460,320,460. delegate = self; refreshView. backgroundColor = [UIColor blackColor]; [_ tableView addSubview: refreshView]; [refreshView Preview];} # pragma-mark-UITableViewDelegate-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section {return 1;}-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath {return 105;}-(CGFloat) tableView :( UITableView *) tableView heightForHeaderInSection :( NSInteger) section {return 30;}-(NSInteger) numberOfSectionsInTableView :( UITableView *) tableView {return 3;}-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: @ "ID"]; if (cell = nil) {cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier: @ "ID"];} cell. selected = NO; if (indexPath. section = 0) {cell. textLabel. text = @ "0"; cell. backgroundColor = [UIColor greenColor];} else if (indexPath. section = 1) {cell. textLabel. text = @ "1"; cell. backgroundColor = [UIColor redColor];} else if (indexPath. section = 2) {cell. textLabel. text = @ "2"; cell. backgroundColor = [UIColor orangeColor];} return cell;}-(UIView *) tableView :( UITableView *) tableView viewForHeaderInSection :( NSInteger) section {UIView * view = [[UIView alloc] initWithFrame: CGRectMake (0, 0,320, 30)]; view. backgroundColor = [UIColor blackColor]; UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake (10, 0,100, 30)]; label. backgroundColor = [UIColor clearColor]; label. textColor = [UIColor whiteColor]; if (section = 0) {label. text = @ "movie";} else if (section = 1) {label. text = @ "TV series";} else if (section = 2) {label. text = @ "Anime";} [view addSubview: label]; return view;} # pragma-mark-EGORefreshTableHeaderDelegate // return whether the current status is refreshed or refreshing-(BOOL) updated :( EGORefreshTableHeaderView *) view {return isloading;} // return the refresh time-(NSDate *) egorefreshtableheader1_celastupdated :( EGORefreshTableHeaderView *) view {return [NSDate date];} // pull-down trigger event-(void) Events :( EGORefreshTableHeaderView *) view {isloading = YES; // update data} # pragma-mark-callback-(void) scrollViewDidEndDragging :( UIScrollView *) scrollView willDecelerate :( BOOL) decelerate {[refreshView preview: scrollView];}-(void) scrollViewDidScroll :( UIScrollView *) scrollView {[refreshView preview: scrollView];}

 


How can I create an animation for the tableView section header?

-(UIView *) tableView :( UITableView *) tableView viewForHeaderInSection :( NSInteger) section {_ tableHeader = [[UIView alloc] initWithFrame: CGRectMake (0, 0,320,100)]; _ tableHeader. backgroundColor = [UIColor redColor]; _ tableHeader. alpha = 0; [UIView animateWithDuration: 1.0 animations: ^ {[_ tableHeader setAlpha: 1.0f] ;}]; return _ tableHeader ;}

In iOS development, sliding Delete of tableview. How can I delete the section header when cell in section is deleted to zero?

-(CGFloat) tableView :( UITableView *) tableView heightForHeaderInSection :( NSInteger) section
You can reset the section header height.
 

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.