首先,这里是显示uiviewcontroller的代码,其中包含uitableview:
//View Controller with navigation bar
InAppPurchaseViewController *purchaseViewController = [[InAppPurchaseViewController alloc] init];
purchaseViewController.title = @"Liste de packs";
purchaseViewController.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissViewController:)] autorelease];
//Creation de la navigation bar et release du viewcontroller
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:purchaseViewController] autorelease];
[purchaseViewController release];
container = [[UIViewController alloc] init];
[container setView:[[CCDirector sharedDirector] openGLView]];
[container setModalTransitionStyle: UIModalTransitionStyleCoverVertical];
[container presentModalViewController: navController animated: YES];
这是我的uitableviewcell:
InAppPurchaseCell.h
@interface InAppPurchaseCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIImageView *ImageThumbnail;
@property (strong, nonatomic) IBOutlet UIButton *BuyButton;
@property (strong, nonatomic) IBOutlet UILabel *TitleLabel;
@property (strong, nonatomic) IBOutlet UILabel *PriceLabel;
@end
InAppPurchaseCell.m
@implementation InAppPurchaseCell
@synthesize PriceLabel;
@synthesize TitleLabel;
@synthesize BuyButton;
@synthesize ImageThumbnail;
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
}
@end
InAppPurchaseCell.xib
所有iboutlet均已正确链接
和:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifierCasual = @"ShopCell";
InAppPurchaseCell *cell = (InAppPurchaseCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifierCasual];
if (cell == nil)
{
cell = (InAppPurchaseCell*)[[[NSBundle mainBundle] loadNibNamed:@"InAppPurchaseCell" owner:nil options:nil]lastObject];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
else
{
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
Packages *packages = [PackagesParser loadData];
Package *package = [packages.Packages objectAtIndex:indexPath.row];
cell.ImageThumbnail.image = [UIImage imageNamed:@"Icon-Small.png"];
cell.PriceLabel.text = @"0,75$";
cell.TitleLabel.text = package.Name;
return cell;
}
桌子弹出时发生了什么?
2012-07-13 13:56:55.378 Testing[1276:1c103] *** Terminating app due to uncaught
exception 'NSUnknownKeyException', reason: '[<NSObject 0xa10da00>
setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key ImageThumbnail.'
在这一行:
cell = (InAppPurchaseCell*)[[[NSBundle mainBundle] loadNibNamed:@"InAppPurchaseCell" owner:nil options:nil]lastObject];
有人有主意吗?
最佳答案
这可能对您有帮助
InAppPurchaseCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
cell=[[InAppPurchaseCell alloc]initWithFrame:CGRectMake(0, 0, 200, 100)
reuseIdentifier:@"ShopCell"];
}
关于iphone - 在cocos2d层顶部的uitableview中制作自定义uitableviewcell,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11470518/