popoverController として表示する tableView のサイズを 4*rowheight に設定しました。そして、tableViewで12セルを使用しています。各セルには、画像とラベルが含まれています。スクロールするとすべてのセルが表示されます。5番目のセルまでは問題ありません。th2 5 番目のセルの後、最初の 4 つのセルで使用しているラベルと画像が、残りのセルに対して繰り返されます。セルを選択すると、結果が正確に表示されます。
しかし、もう一度 tableView を取得すると、最初の 5 つのセルでも画像とラベルが正確ではありません。すべてが変更されていますが、選択によって正しい結果が得られています。誰でも私を助けることができますか??
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [self tableviewCellWithReuseIdentifier:CellIdentifier rowNumber:indexPath.row];
}
//tableView.backgroundColor = [UIColor clearColor];
return cell;
}
- (UITableViewCell *)tableviewCellWithReuseIdentifier:(NSString *)identifier rowNumber:(NSInteger)row
{
CGRect rect;
rect = CGRectMake(0.0, 0.0, 360.0, ROW_HEIGHT);
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:rect reuseIdentifier:identifier] autorelease];
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10.00, 10.00, 150.00, 100.00)];
myImageView.tag = IMAGE_TAG;
[cell.contentView addSubview:myImageView];
[myImageView release];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(170.00, -10.00, 170.00, 80.00)];
label.tag = LABEL_TAG;
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor blackColor]];
[label setFont:[UIFont fontWithName:@"AmericanTypewriter" size:22]];
[label setTextAlignment:UITextAlignmentLeft];
[cell.contentView addSubview:label];
[label release];
if (row == 0)
{
UIImageView *imageView = (UIImageView *)[cell viewWithTag:IMAGE_TAG];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"cover_v.jpg"]];
UILabel *mylabel = (UILabel *)[cell viewWithTag:LABEL_TAG];
mylabel.text = [NSString stringWithFormat:@"COVER PAGE"];
}
}