3
我的UITableView nedd在第一行中有一個圖像。 什麼問題?當用戶向下滾動桌面視圖時,然後向上滾動,在圖像上顯示其他行的信息! 你知道爲什麼嗎?UITableview中的第一行,與其他行不同
這是我的代碼(我使用一個UITableViewCell)
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row != 0) {
return 73.0;
}
else {
return 109.0;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
if (indexPath.row == 0) {
[[NSBundle mainBundle] loadNibNamed:@"customcell_3" owner:self options:NULL];
cell = cellaNib_with_image;
}
else {
[[NSBundle mainBundle] loadNibNamed:@"customcell_2" owner:self options:NULL];
cell = cellaNib;
}
}
if (indexPath.row == 0) {
UIImage *rowBackground;
UIImage *selectionBackground;
rowBackground = [UIImage imageNamed:@"image.png"];
selectionBackground = [UIImage imageNamed:@"image.png"];
cell.backgroundView = [[[UIImageView alloc] init] autorelease];
((UIImageView *)cell.backgroundView).image = rowBackground;
cell.selectedBackgroundView = [[[UIImageView alloc] init] autorelease];
((UIImageView *)cell.selectedBackgroundView).image = selectionBackground;
}
else {
NSString *elemento = [NSString stringWithFormat:@"%@", [array objectAtIndex:indexPath.row]];
UILabel *testoLabel = (UILabel*)[cell viewWithTag:1];
testoLabel.text = elemento;
//ecc... here a take the other datas
}
return cell;
}
謝謝!
對!!!非常感謝你!!! :) – JAA
你需要將你只使用一次的細胞出列嗎? –