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