gpt4 book ai didi

iphone - 在 cocos2d 层顶部的 uitableview 中制作自定义 uitableviewcell

转载 作者:行者123 更新时间:2023-11-29 13:32:42 24 4
gpt4 key购买 nike

首先是显示包含 uitableview 的 uiviewcontroller 的代码:

//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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com