IOS Original Ecological refresh control-UIRefreshControl

Source: Internet
Author: User

IOS Original Ecological refresh control-UIRefreshControl

//

// ViewController. m

// Code custom cell

//

// Created by Macon 15/4/18.

// Copyright (c) 2015 mac. All rights reserved.

//

 

# Import "ViewController. h"

// # Import "myTableViewCell. h"

@ Interface ViewController ()

 

@ End

 

@ Implementation ViewController

 

-(Void) viewDidLoad {

[Super viewDidLoad];

 

[Self addArrayM];

_ MyTableView = [[UITableView alloc] initWithFrame: [UIScreen mainScreen]. bounds style: UITableViewStylePlain];

_ MyTableView. delegate = self;

_ MyTableView. dataSource = self;

_ MyTableView. backgroundColor = [UIColor whiteColor];

[Self. view addSubview: _ myTableView];

[_ MyTableView reloadData];

 

/****** Common property settings for built-in refresh ******/

_ Refresh = [[UIRefreshControl alloc] init];

_ Refresh. tintColor = [UIColor redColor];

_ Refresh. attributedTitle = [[NSAttributedString alloc] initWithString: @ ""];

[_ Refresh addTarget: self action: @ selector (pullToRefresh) forControlEvents: UIControlEventValueChanged];

 

[_ MyTableView addSubview: _ refresh];

 

// UIActivityViewController * act = [[UIActivityViewController alloc] initw];

// Do any additional setup after loading the view, typically from a nib.

}

-(Void) pullToRefresh

{

[Self. arrayM addObjectsFromArray: self. arrayM];

[_ MyTableView reloadData];

[NSTimer scheduledTimerWithTimeInterval: 2.0 target: self selector: @ selector (timerStop) userInfo: nil repeats: NO];

}

-(Void) timerStop

{

[_ Refresh endRefreshing];

 

}

-(Void) addArrayM

{

NSString * one = @ "";

NSString * one1 = @ "B ";

NSString * one11 = @ "C ";

NSString * one111 = @ "D ";

NSString * one1111 = @ "E ";

NSString * one11111 = @ "F ";

NSString * one111111 = @ "G ";

_ ArrayM = [NSMutableArray arrayWithObjects: one, one1, one11, one111, one1111, one11111, one111111, nil];

}

-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section

{

Return [_ arrayM count];

}

-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath

{

Static NSString * ID = @ "cell ";

UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: ID];

If (! Cell ){

Cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: ID];

 

 

 

}

Cell. imageView. image = [UIImage imageNamed: @ "iosshare"];

Cell. textLabel. text = [_ arrayM objectAtIndex: indexPath. row];

Return cell;

}

-(Void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath

{

 

NSLog (@ "Click me ");

}

-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath

{

 

 

Return 80;

}

-(Void) didReceiveMemoryWarning {

[Super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

 

@ End


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.