转载:http://www.2cto.com/kf/201504/392431.html

//

// ViewController.m

// 代码自定义cell

//

// Created by mac on 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];

/******内置刷新的常用属性设置******/

_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 = @"A";

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(@"点击我了");

}

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

{

return 80;

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

最新文章

  1. jquery属性
  2. Python基础、异常处理
  3. python: extend (扩展) 与 append (追加) 的差别
  4. Spring的循环依赖问题
  5. Python学习总结9:目录操作方法汇总
  6. Gson心得小笔记
  7. WebRTC录音(1)-实现通话双向录音
  8. ChinaUnix上的帮助手册还不错!
  9. Hbase与hive整合
  10. NeatUpload 同时选择并上传多个文件
  11. C++描述基础算法之直接插入排序
  12. 关于帝国cms 列表页SEO优化的问题
  13. springmvc学习(四)
  14. dynamic 使用
  15. Grails教程
  16. 使用EXCEL设置“下拉菜单”选项功能
  17. oracle创建user具体指示
  18. 浅谈java中==与equals的区别
  19. Docker到底是什么
  20. Python assert作用

热门文章

  1. 使用HttpClient工具类测试Http接口
  2. Python第三方库安装技巧
  3. VBS基础篇 - 循环语句(3) - For...Next
  4. MFC模态和非模态对话框编程
  5. Volist标签
  6. 安装lnmp(linux nginx mysql php)
  7. Lotto
  8. Angularjs Directive(指令)机制
  9. Python 线程,进程
  10. hibernate ——联合主键