setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
先说解决办法吧:
发布日期:2021-09-28 18:46:27
浏览次数:17
分类:技术文章
本文共 1165 字,大约阅读时间需要 3 分钟。
今天在写自定义UITableViewCell的时候遇到一个Crash,特别无语,折腾了大半天,终于解决了。
Bug如下:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x8a4b500> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key strss.' |
然后讲故事:
1.如何使用IOS UITableView?
参考:http://blog.csdn.net/h3c4lenovo/article/details/8307253
2.如何使用自定义的UITableViewCell实现UITableView?
参考:http://www.howzhi.com/group/iosDevelop/discuss/2068
3.单独创建的xib/nib文件如何与.h/.m文件关联起来?
定义xib中File's Owner 或 View的Custom Class 如上图所示。注:网上大部分说报错的原因要么就是存在无效的连接,或者File's Owner的custom class没有连接。
4.代码中如何引用自定义的TableViewCell?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CustomCellIdentifier = @"testCellIdentifier"; static BOOL nibsRegistered = NO; if (!nibsRegistered) { UINib *nib = [UINib nibWithNibName:@"testCell" bundle:nil]; [tableView registerNib:nib forCellReuseIdentifier:CustomCellIdentifier]; nibsRegistered = YES; } testCell *cell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier]; [cell setMyText:@"xxx"]; return cell;}
转载地址:https://blog.csdn.net/h3c4lenovo/article/details/8556887 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2024年04月25日 20时18分35秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
AcWing - 满足条件的01序列(组合数学&卡特兰数)
2019-04-28
AcWing - 快速排序(快排)
2019-04-28
AcWing - 归并排序(归排)
2019-04-28
AcWing - 数的范围(二分)
2019-04-28
AcWing - 数的三次方根(二分)
2019-04-28
AcWing - 高精度加法(大数加法)
2019-04-28
AcWing - 高精度减法(大数减法)
2019-04-28
AcWing - 高精度乘法(大数乘法)
2019-04-28
AcWing - 高精度除法(大数除法)
2019-04-28
AcWing - 前缀和(前缀和)
2019-04-28
AcWing - 子矩阵的和(二维前缀和)
2019-04-28
AcWing - 差分(一维差分)
2019-04-28
AcWing - 最长连续不重复子序列(双指针)
2019-04-28
AcWing - 数组元素的目标和(双指针)
2019-04-28
AcWing - 区间和(离散化&前缀和)
2019-04-28
AcWing - 区间合并(贪心)
2019-04-28
AcWing - 单链表(模拟)
2019-04-28
AcWing - 双链表(模拟)
2019-04-28
AcWing - KMP字符串(KMP)
2019-04-28
来一个总结吧
2019-04-28