'无法实例化名为UITableViewCellContentView的类'iPhone 3.1.2 [英] 'Could not instantiate class named UITableViewCellContentView' iPhone 3.1.2
问题描述
我为自定义UITableView单元格创建了一个笔尖,并按照文档和其他教程来克服此错误,并且它不会停止.我研究了此错误,人们说这是在#import标头但未添加Framework的时候.好吧,UIKit是自动添加的,为了方便起见,我删除并再次添加了它,并且此错误不会消失.这是我的- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
I've created a nib for a custom UITableView cell and followed the documentation and different tutorials to get past this error and it just won't let up. I researched this error and people say it's when you #import a header but you didn't add the Framework. Well, UIKit is automatically added, and I removed and added it again for good measure and this error won't let up. Here is my code for - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *MyIdentifier = @"PersonCell";
PersonCell *cell = (PersonCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"PersonCell" owner:self options:nil];
cell = personCell;
}
return cell;
推荐答案
在开发者论坛中找到解决方案
Found solution in dev forums
创建此文件:
UITableViewCellContentView.h
UITableViewCellContentView.h
#import <UIKit/UIKit.h>
@interface UITableViewCellContentView : UIView {
}
UITableViewCellContentView.m
UITableViewCellContentView.m
@implementation UITableViewCellContentView
+ (id)alloc {
return [UIView alloc];
}
+ (id)allocWithZone:(NSZone *)zone {
return [UIView allocWithZone:zone];
}
@end
这篇关于'无法实例化名为UITableViewCellContentView的类'iPhone 3.1.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!