首页 > 移动平台 > 详细

IOS开发UITableView --UITableView

时间:2016-05-09 20:10:52      阅读:89      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!