ios - UITableViewCell 重用问题,关于Button highlighted 显示不正确
天蓬老师
天蓬老师 2017-04-18 09:18:07
[iOS讨论组]
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CarDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifyCarDetail forIndexPath:indexPath];
    NSLog(@"fenceName.text:%@ cell.infenceBtn:%d", cell.fenceName.text, cell.infenceBtn.highlighted);
    CarFence *carFence = self.carDetail.fence[indexPath.row];
    NSLog(@"carFence:%@ inFence:%d", carFence.fenceName, carFence.inFence);
    cell.fenceName.text = carFence.fenceName;
    cell.infenceBtn.highlighted = !carFence.inFence;
    NSLog(@"==================================");
    return cell;
}

cell.infenceBtn.highlighted = !carFence.inFence;
这句是接口遗留问题。

cell.fenceName.text = carFence.fenceName;
这句对应显示是正确的
第二行的按钮highlighted 不正确

所有测试3的log 均正确

初始 - fenceName.text:测试3 cell.infenceBtn:0 //cell 进入代理时的状态
数据 - carFence:测试3 inFence:0 //这里数据是正确的,因为要取反
完成 - cell.fenceName:测试3 Btn.highlighted:1 // 正确,设置后的Btn.highlighted 状态。

我把修改了XIB 的Default 和 highlighted 使之对应就好了
原因可能和XIB 的加载有关,请问究竟是哪里的问题。

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回复(1)
ringa_lee

原因找到了 Btn 用户交互没有关

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号