@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;
}
代码创建tableView
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- http://blog.csdn.net/syg90178aw/article/details/46981277
- 很久没更了,感觉学习的很基础的东西没什么好写的,网上也一大把,但是发现写博客的一大好处就是,你忘记了一个知识点可以...
- 使用XIB创建cell的时候,高度自适应,将这两句代码放进viewdidLoad轻松实现
- UITableViewController *tvc =[[UITableViewController alloc...