码迷,mamicode.com
首页 > 移动开发 > 详细

IOS开发UITableView --UITableView

时间:2016-05-09 20:13:10      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:

UITableView的两种样式
UITableViewStylePlain 不分组显示
UITableViewStyleGrouped 分组显示   
 

UITableViewDataSource  //数据源协议

两个必需实现的方法
//一组有多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//每一行显示什么内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
   
    // 设置分隔线颜色
    self.tableView.separatorColor = [UIColor colorWithRed:35/255.0 green:136/255.0 blue:255/255.0 alpha:119/255.0];
   
    // 设置分隔线style
//    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
   
    // tableHeaderView广告位
    self.tableView.tableHeaderView = [[UISwitch alloc] init];
    // 加载更多
    self.tableView.tableFooterView = [UIButton buttonWithType:UIButtonTypeContactAdd];
 
 
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{    // 1.定义一个cell的标识

      static NSString *ID = @"mjcell";

    // 2.从缓存池中取出cell

      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];

    // 3.如果缓存池中没有cell

      if (cell == nil) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];

    }

    // 4.设置cell的属性...

 
       return cell;
 
 
点击每行单元格中的cell显示什么内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

IOS开发UITableView --UITableView

标签:

原文地址:http://www.cnblogs.com/MJC-IOS-2010/p/5474996.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!