setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
2017-05-08 16:17
1016 查看
http://blog.csdn.net/h3c4lenovo/article/details/8556887
今天在写自定义UITableViewCell的时候遇到一个Crash,特别无语,折腾了大半天,终于解决了。
Bug如下:
先说解决办法吧:
然后讲故事:
plain copy
- (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;
}
今天在写自定义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/83072532.如何使用自定义的UITableViewCell实现UITableView?
参考:http://www.howzhi.com/group/iosDevelop/discuss/20683.单独创建的xib/nib文件如何与.h/.m文件关联起来?
定义xib中File's Owner 或 View的Custom Class 如上图所示。注:网上大部分说报错的原因要么就是存在无效的连接,或者File's Owner的custom class没有连接。4.代码中如何引用自定义的TableViewCell?
[cpp] viewplain copy
- (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;
}
相关文章推荐
- ... setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key latitudeLabel.
- ... setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key latitudeLab
- question:setValue:forUndefinedKey: this class is not key value coding-compliant for the key
- *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<WKWebViewConfiguration 0x1701bcd20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the k
- iOS Xcode 6报错:setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key v
- setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
- setValue:forUndefinedKey this class is not key value coding-compliant for the key
- setValue:forUndefinedKey this class is not key value coding-compliant for the key
- iOS- 报错(崩)[< > setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
- iOS: setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.
- iOS: setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.
- xib自定义UIView报错误 "forUndefinedKey:]: this class is not key value coding-compliant for the key"
- setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.
- setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
- xib自定义UIView报错误 "forUndefinedKey:]: this class is not key value coding-compliant for the key"
- setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
- setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
- setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key解决办法
- iOS setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key 问题
- swift4.0 valueForUndefinedKey:]: this class is not key value coding-compliant for the key unity.'