나는 사용자 정의 셀이있는 테이블이 있습니다. 이 셀에는 셀에서 이동하려는 레이블이 있습니다 (조건이 참인 경우). 해당 셀의 cellForRowAtIndexPath 메소드가 두 번째로 호출 된 경우에만 레이블의 위치가 업데이트되는 이유는 무엇입니까?TableViewCell - 사용자 정의 셀 IOS - 내용
이것은 첫 번째 질문입니다. 다음
번째 문제는이다 : 맞춤 셀 프로그래밍 방식의 이미지를 추가 이러한 관점에서, 도면을 포함한다. 테이블에 두 개의 섹션이있는 경우 테이블을 스크롤 한 후 첫 번째 섹션의 첫 번째 셀 이미지가 두 번째 섹션의 첫 번째 셀에 나타납니다. 왜?
이
코드를 사전에- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *idDettCal = @"cellaVotoCalciatore";
NSString *idRiepilogo = @"riepilogoCell";
NSString *idTotali = @"bonusTotaliCell";
//Dictionary per Titolari e Panchinari
NSDictionary *calciatore = [[NSDictionary alloc] init];
if (indexPath.section == 0 || indexPath.section == 1) {
foaVotoCalciatoreCell *cell = (foaVotoCalciatoreCell *)[tableView dequeueReusableCellWithIdentifier:idDettCal];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:idDettCal owner:self options:nil];
cell = [nib objectAtIndex:0];
}
//TITOLARI
if (indexPath.section == 0) {
calciatore = [titolari objectAtIndex:indexPath.row];
}
//PANCHINARI
else if (indexPath.section == 1) {
calciatore = [panchinari objectAtIndex:indexPath.row];
}
NSString *calciatoreStr =
[NSString stringWithFormat:@"%@%@%@%@",
[calciatore objectForKey:@"CALCIATORE"],
@" (",
[[calciatore objectForKey:@"SQUADRA"] substringToIndex:3],
@")"];
NSString *imgRuolo =
[NSString stringWithFormat:@"%@%@",
[calciatore objectForKey:@"RUOLO"],
@".jpg"];
cell.ruolo.image = [UIImage imageNamed:imgRuolo];
NSDictionary *dettaglioVoto = [[NSDictionary alloc] init];
UIImageView *imageIcona;
CGFloat offset;
dettaglioVoto = [calciatore objectForKey:@"VOTO_STM"];
offset = 0;
for (NSString *icona in dettaglioVoto) {
if ([icona isEqualToString: @"AMMONITO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"amm.png"]];
}
else if ([icona isEqualToString: @"GOL_FATTO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"golfatto.png"]];
}
else if ([icona isEqualToString: @"GOL_SUBITO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"golsubito.png"]];
}
else if ([icona isEqualToString: @"ENTRATO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"entrato.png"]];
}
else if ([icona isEqualToString: @"USCITO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"uscito.png"]];
}
else if ([icona isEqualToString: @"ESPULSO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"esp.png"]];
}
else if ([icona isEqualToString: @"ASSIST"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"assist.png"]];
}
else if ([icona isEqualToString: @"ASSIST_FERMO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"assistf.png"]];
}
else if ([icona isEqualToString: @"RIGORE_SEGNATO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rigoresegnato.png"]];
}
else if ([icona isEqualToString: @"RIGORE_SBAGLIATO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rigoresbagliato.png"]];
}
else if ([icona isEqualToString: @"RIGORE_PARATO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rigoreparato.png"]];
}
else if ([icona isEqualToString: @"AUTOGOL"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"autogol.png"]];
}
else if ([icona isEqualToString: @"GOL_PARTITA"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"golvittoria.png"]];
}
else if ([icona isEqualToString: @"GOL_PAREGGIO"]) {
imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"golpareggio.png"]];
}
imageIcona.frame = CGRectMake(offset, 0, imageIcona.frame.size.width, imageIcona.frame.size.height);
offset = imageIcona.frame.size.width + offset + 2;
[cell.iconeDettaglio addSubview: imageIcona];
}
if (offset == 0) {
cell.calciatore.frame = CGRectMake(cell.calciatore.frame.origin.x, 14, cell.calciatore.frame.size.width, cell.calciatore.frame.size.height);
cell.iconeDettaglio.hidden = YES;
}
cell.calciatore.text = calciatoreStr;
cell.votoIniziale.text = [calciatore objectForKey:@"VOTO_PRNT"];
cell.votoFinale.text = [calciatore objectForKey:@"VOTO_PRNT_TOT"];
return cell;
}
//La giornata è calcolata. Sezione 2 = BONUS e TOTALI
else if (variabiliGlobali.gioCalcolata && indexPath.section == 2) {
NSDictionary *totaliVal;
NSDictionary *totaliTip;
totaliVal = [logCalValore objectAtIndex:indexPath.row];
totaliTip = [logCalTipo objectAtIndex:indexPath.row];
foaBonusTotaliCell *cell = (foaBonusTotaliCell *)[tableView dequeueReusableCellWithIdentifier:idTotali];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:idTotali owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.tipoBonusLabel.text = totaliTip;
cell.totaleLabel.text = totaliVal;
return cell;
}
else {
NSDictionary *riepilogoVal;
NSDictionary *riepilogoTip;
riepilogoVal = [logForValore objectAtIndex:indexPath.row];
riepilogoTip = [logForTipo objectAtIndex:indexPath.row];
foaRiepilogoCell *cell = (foaRiepilogoCell *)[tableView dequeueReusableCellWithIdentifier:idRiepilogo];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:idRiepilogo owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.voceRiepilogoLabel.text = riepilogoTip;
cell.valoreRiepilogoLabel.text = riepilogoVal;
return cell;
}
}
감사합니다.
관련 코드를 게시해야 문제를 해결할 수 있습니다. – rmaddy
코드를 게시했습니다 –
이미지를 삽입했습니다. 첫 번째는 테이블이 나타날 때입니다. 두 번째는 두루마리 뒤에 있습니다. –