カスタム UITableVieCell を TableView に実装しようとしています。セル内には、間違ったプロパティを取得している 2 つのサブビューがあります。
ここに私の tableView:cellForRowAtIndexPath: があります:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
ListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[ListCell alloc] initWithFrame:CGRectMake(0, 0, 320.0f, 70.0f)];
}
return cell;
}
カスタム Cell ListCell からの 2 つの init-methods は次のとおりです。
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.frame = frame;
cellBack = [[ListCellBack alloc] initWithFrame:CGRectMake(0.0, 0.0, frame.size.width, frame.size.height)];
cellFront = [[ListCellFront alloc] initWithFrame:CGRectMake(0.0, 0.0, frame.size.width, frame.size.height)];
[self.contentView addSubview:cellBack];
[self.contentView addSubview:cellFront];
slideEnabled = YES;
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
if (self) {
}
return self;
}
それが解決策です:
そしてそれが私の目標です:
そのため、カスタム セルの 2 つのサブビューが間違ったフレーム番号を取得しています。私はこれに何時間も苦労しています!
前もって感謝します!