tableView简化写法

来源:互联网 发布:淘宝助理设置快递模板 编辑:程序博客网 时间:2024/06/05 06:30
#import "MyTableViewController.h"@interface MyTableViewController ()@property(nonatomic,retain)NSMutableArray *arr;@end@implementation MyTableViewController- (void)viewDidLoad {    [super viewDidLoad];     self.arr = [NSMutableArray arrayWithObjects:@"宋江", @"卢俊义", @"吴用", @"公孙胜", @"关胜", @"林冲", @"秦明" ,@"呼延灼" , @"花荣",@"柴进", @"李应", @"朱仝",@"鲁智深",@"武松", @"徐宁", @"张清", @"杨志", @"董平", @"索超", @"戴宗", @"刘唐", @"李逵", @"史进", @"穆弘", @"雷横", @"李俊",nil];    ////tableView的对cell的注册    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuse"];    self.refreshControl=[[UIRefreshControl alloc] init];    [self.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];}-(void)refresh:(UIRefreshControl *)control{    NSLog(@"11111");}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}#pragma mark - Table view data source- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {    return 1;}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {    return self.arr.count;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse" forIndexPath:indexPath];    cell.textLabel.text=self.arr[indexPath.row];    return cell;}
0 0
原创粉丝点击