• 知乎日报--第四周



    提示:以下是本篇文章正文内容,下面案例可供参考

    关于cell复用

    之前一直没有解决cell复用的问题
    在函数里加上如下代码即可:

    - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        
        NSString* str = [NSString stringWithFormat:@"%ld%ld",indexPath.section,indexPath.row];
        UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:str];
        if (cell == nil){
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"111"];
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    解决cell的复用问题后下拉刷新就解决了
    在这里插入图片描述

    cell的section之间的标题

    - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
        UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
        header.contentView.backgroundColor= [UIColor clearColor];
        header.textLabel.text = @“标题”;
        [header.textLabel setFont:[UIFont systemFontOfSize:20]];
    }
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
        return @"111"; 
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    cell的section的高度

    我这里需要让cell的第一个section的高度为0,其他的section的高度相同

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
        if (section == 0){
            return 0;
        } else{
            return 20;
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    关于取消导航栏

    我这里的导航栏使用的是一个自定义的view来做了一个假导航栏
    但是有时候需要去掉这个导航栏
    [self.navigationController pushViewController:woDeView animated:NO];
    这行代码的意思就是跳转到woDeView界面并取消导航栏

    - (void)pressWoDe{
        WoDeViewController* woDeView = [[WoDeViewController alloc] init];
        woDeView.modalPresentationStyle = UIModalPresentationFullScreen;
        woDeView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentViewController:woDeView animated:YES completion:nil];
        [self.navigationController pushViewController:woDeView animated:NO];
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
  • 相关阅读:
    人工智能轨道交通行业周刊-第61期(2023.9.18-9.24)
    [NOI2022] 众数 题解
    linux
    【团队协作】都2022年了,前后端合作开发还不使用Apifox?
    数据结构——线性表的顺序表示和实现
    百度java面试学习小总结
    Vue3的12种组件通信方式(附代码)
    分库分表总结
    对象引用、可变性和垃圾回收
    PostMan工具介绍及安装使用
  • 原文地址:https://blog.csdn.net/weixin_61196797/article/details/127835928