s_k*_*les 4 objective-c uitableview ios nsunknownkeyexception
我正在使用一个自定义UITableViewCell,它已经有一些完全有效的UI元素.但是,我只是尝试为它们添加两个标签,当我连接插座并调用时cell.label.text = @"text";,程序崩溃并出现错误:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FeedTableViewCell 0x7aa53d00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key likesLabel.'
我检查了是否有任何没有元素的连接,但没有.当除了新UI元素之外的所有内容都添加到单元格时,该应用程序完全有效 就在我添加应用程序崩溃的新UI元素时.这是什么问题?
自定义单元类.h
#import <UIKit/UIKit.h>
@interface FeedTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *profileImage;
@property (weak, nonatomic) IBOutlet UITextView *questionTextView;
@property (weak, nonatomic) IBOutlet UIButton *usernameButton;
@property (weak,nonatomic) IBOutlet UILabel * likesLabel;
@end
Run Code Online (Sandbox Code Playgroud)
喜欢的标签是问题的出路
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object{
FeedTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[FeedTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
cell.likesLabel.text = @"text";
return cell;
}
Run Code Online (Sandbox Code Playgroud)
电池的插座连接:

| 归档时间: |
|
| 查看次数: |
7779 次 |
| 最近记录: |