У меня есть этот класс ячеек (ModelPortrait2TableViewCell.h):
@interface ModelPortrait2TableViewCell : UITableViewCell
{
UILabel *imageLabel;
UILabel *imageLabel2;
UIButton *boton;
UIButton *boton2;
}
@property (nonatomic, retain) UILabel *imageLabel;
@property (nonatomic, retain) UILabel *imageLabel2;
@property (nonatomic, retain) UIButton *boton;
@property (nonatomic, retain) UIButton *boton2;
+ (id)cell;
ModelPortrait2TableViewCell.m
@synthesize imageLabel;
@synthesize imageLabel2;
@synthesize boton;
@synthesize boton2;
+ (id)cell
{
ModelPortrait2TableViewCell *cell = [[[ModelPortrait2TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ModelPortrait2TableViewCell"] autorelease];
float anchoDefinido = [GlobalData sharedGlobalData].width;
float altoDefinido = [GlobalData sharedGlobalData].height;
float spaceX = [GlobalData sharedGlobalData].spaceBetweenImagesPortraitWidth;
float spaceY = [GlobalData sharedGlobalData].spaceBetweenImagesPortraitHeight;
cell.imageLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
[cell.imageLabel setFrame:CGRectMake(spaceX,(altoDefinido-spaceY)+10.0,anchoDefinido,20)];
[cell.imageLabel setTextAlignment:UITextAlignmentCenter];
[cell.imageLabel setFont:[UIFont systemFontOfSize:11]];
[cell.imageLabel setBackgroundColor:[UIColor clearColor]];
cell.imageLabel2 = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
[cell.imageLabel2 setFrame:CGRectMake((anchoDefinido+spaceX+spaceX),(altoDefinido-spaceY)+10.0,anchoDefinido,20)];
[cell.imageLabel2 setTextAlignment:UITextAlignmentCenter];
[cell.imageLabel2 setFont:[UIFont systemFontOfSize:11]];
[cell.imageLabel2 setBackgroundColor:[UIColor clearColor]];
cell.boton = [UIButton buttonWithType:UIButtonTypeCustom];
[cell.boton setFrame: CGRectMake(spaceX,spaceY,anchoDefinido,altoDefinido)];
cell.boton.backgroundColor = [UIColor redColor];
cell.boton2 = [UIButton buttonWithType:UIButtonTypeCustom];
[cell.boton2 setFrame: CGRectMake((anchoDefinido+spaceX+spaceX),spaceY,anchoDefinido,altoDefinido)];
cell.boton2.backgroundColor = [UIColor redColor];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
return cell;
}
Я пытаюсь получить доступ к этой ячейке из моего UITableViewController, но я не могу.
Мой код:
ModelPortrait2TableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:@"ModelPortrait2TableViewCell"];
if (!cell)
{
cell = [ModelPortrait2TableViewCell cell];
}
[[cell boton] setFrame:imview.frame];
[[cell boton] setImage:imview.image forState:UIControlStateNormal];
[[cell boton] addTarget:self action:@selector(showInfo:) forControlEvents:UIControlEventTouchUpInside];
[[cell boton] setTitle:[articulo objectForKey:@"Modelo"] forState:UIControlStateNormal];
[[cell boton] setTag:imagen0];
[[cell imageLabel] setText:[articulo objectForKey:@"Modelo"]];
или
cell.boton.frame = imview.frame;
[cell.boton setImage:imview.image forState:UIControlStateNormal];
[cell.boton addTarget:self action:@selector(showInfo:) forControlEvents:UIControlEventTouchUpInside];
[cell.boton setTitle:[articulo objectForKey:@"Modelo"] forState:UIControlStateNormal];
[cell.boton setTag:imagen0];
[cell.imageLabel setText:[articulo objectForKey:@"Modelo"]];
Я не могу изменить свою ячейку с моего контроллера ... Любое решение ???