Tôi đã xem xét hầu hết các câu hỏi liên quan về điều này ở đây trong stackoverflow và đã thử tất cả các giải pháp có thể của họ nhưng tôi vẫn không thể hiểu tại sao tôi nhận được lỗi này:Lớp con UITableViewCell tùy chỉnh: Lớp này không phải là giá trị khóa tuân thủ
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CustomCell 0x6e627d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key title.'
Tôi đang cố tải ô xem bảng tùy chỉnh bằng nibname: @ "CustomCell". Lớp của nó được gán cho "CustomCell" (cùng tên lớp với tên nib). Chủ sở hữu tệp của nó cũng được đặt thành lớp tải các ô này - "ProductsTableViewControllerWithSearch". Tất cả các cửa hàng trong nib được kết nối với những người thân trong CustomCell.m
Dưới đây là mã của tôi:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellClassName = @"CustomCell";
static NSString *CellIdentifier = @"Custom Items Cell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLevelItems = [[UINib nibWithNibName:CellClassName bundle:[NSBundle mainBundle]] instantiateWithOwner:self options:nil];
cell = [topLevelItems objectAtIndex:0];
}
//... more irrelevant code here
}
ai đó có thể giúp tôi xin vui lòng. Tôi đã làm việc này trong hơn 4 giờ. Cảm ơn rất nhiều!
PS: Tôi đang sử dụng ARC và đang phát triển cho iOS 5.
Đây là CustomCell.h của tôi.
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell{
UILabel *textLabel;
UILabel *detailTextLabel;
UIButton *starButton;
}
@property (strong, nonatomic) IBOutlet UILabel *textLabel;
@property (strong, nonatomic) IBOutlet UILabel *detailTextLabel;
@property (strong, nonatomic) IBOutlet UIButton *starButton;
@end
Không có gì trong CustomCell.m tôi
CustomCell là lớp con của? – JoePasq
@JoePasq UITableViewCell. – acecapades