静态动态cell混合使用

需要重写的方法

#pragma mark - Table view data source

- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{

    return [super tableView:tableView titleForHeaderInSection:section];

}

- (NSString*)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

{

    return [super tableView:tableView titleForFooterInSection:section];

}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

{

    return NO;

}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath

{

    return NO;

}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

{

    return [super tableView:tableView heightForFooterInSection:section];

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    if (indexPath.section == 2)

        return 88;

    return [super tableView:tableView heightForRowAtIndexPath:indexPath];

}

- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

{

    return nil;

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return [super numberOfSectionsInTableView:tableView];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    if (section == 2) {

        return self.data.count;

    }

    return [super tableView:tableView numberOfRowsInSection:section];

    

}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    if (section == 0) {

        return 20;

    }

    return 30;

}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

    return [[UIView alloc] init];

}

- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 2) {

        return self.data.count;

    }

    return indexPath.row;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 2) {

        if (self.noticeBtn.selected) {

            YYOneKindCell *cell = [YYOneKindCell cellWithTableView:tableView];

            cell.item = self.data[indexPath.row];

            return cell;

        }else{

            YYOtherKindCell *cell = [YYOtherKindCell cellWithTableView:tableView];

            cell.item = self.data[indexPath.row];

            return cell;

        }

    }

    return [super tableView:tableView cellForRowAtIndexPath:indexPath];

}


[

调用 didSelectRowAtIndexPath。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     [tableView deselectRowAtIndexPath:indexPath animated:YES];

     
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
}

http://www.itstrike.cn/question/cba84b8a-150b-47f3-833b-bb683617c02c.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
QCustomPlot是一个用于绘制二维图表的开源C++库。它提供了丰富的绘图功能,可以绘制静态动态图表。 静态绘图是指在初始化时,绘制一个固定的图表。使用QCustomPlot绘制静态图表的基本步骤如下: 1. 创建一个QCustomPlot对象,该对象承载了整个图表。 2. 调用QCustomPlot对象的成员函数来设置图表的一些属性,如标题、坐标轴、刻度等。 3. 使用数据来填充图表,可以使用QVector或者std::vector等数据容器来存储数据。 4. 使用QCustomPlot对象的成员函数,如addGraph()或者addPlottable(),将数据添加到图表中。 5. 根据需要,可以调整图表的样式,如线条颜色、点的形状等。 6. 最后,调用QCustomPlot对象的replot()函数完成图表的绘制。 动态绘图是指在运行时,根据数据的变化不断更新图表。使用QCustomPlot绘制动态图表的基本步骤如下: 1. 创建一个QCustomPlot对象,该对象承载了整个图表。 2. 调用QCustomPlot对象的成员函数来设置图表的一些属性,如标题、坐标轴、刻度等。 3. 初始化图表,可以添加一些初始数据点。 4. 启动一个定时器,在定时器的槽函数中更新数据。 5. 在槽函数中更新图表,可以使用QCustomPlot对象的成员函数来更新已有的数据,或者添加新的数据点。 6. 最后,调用QCustomPlot对象的replot()函数刷新图表。 需要注意的是,在动态绘图时,由于频繁的数据更新,性能方面可能需要做一些优化,以提高绘图的效率。 总的来说,QCustomPlot库提供了丰富的功能和灵活的接口,可以满足绘制静态动态图表的需求。掌握了基本的使用方法后,可以根据具体的需求进行更高级的定制和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值