• 知乎日报--第四周



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

    关于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
  • 相关阅读:
    14:00面试,14:06就出来了,问的问题有点变态。。。
    MD5 算法流程
    Oracle RAC ASM磁盘组删除、添加磁盘
    Android View拖拽startDragAndDrop,Kotlin
    【实战技能】初级软件开发工程师常见问题
    配置neo4j bolt+s ssl
    前端从零到一开发vscode插件并发布到插件市场
    华为eNSP配置专题-ACL的配置
    解读AI机器人产业发展的顶层设计
    linux 下的java gate服务断掉的原因及解决思路
  • 原文地址:https://blog.csdn.net/weixin_61196797/article/details/127835928