代码创建tableView

@property (strong,nonatomic) UITableView *tableView;
 <UITableViewDelegate,UITableViewDataSource>

- (void)initTableView{
_tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 297, ScrrenWidth,ScrrenHeight-300) style:UITableViewStylePlain];
_tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
_tableView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:1];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.rowHeight = 140;
_tableView.sectionHeaderHeight = 50;
_tableView.indicatorStyle = UITableViewStyleGrouped;
_tableView.contentInset = UIEdgeInsetsMake(0, 0, 10, 0);

    [self.view addSubview:_tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
        return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:16.0f];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
return cell;

}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容