ios objective-c uitableview alignment

ios - Cambio de posición de un UILabel para una UITableVIewCell personalizada



objective-c alignment (1)

Solo verifica el indexpath.row

if (indexpath.row == 2){ cell.liveButton.hidden = YES; CGRect frame = cell.gameTimeLabel.frame; frame.origin.x= 27; // move the label 10pts to the left since no image will be present cell.gameTimeLabel.frame= frame;}

EDITAR ---

Todavía no está 100% claro cuál es exactamente el problema, pero hay un par de cosas que puedes probar.

  1. Restablezca el diseño en layoutSubviews [self.view setNeedsLayout];
  2. Recargue los datos de la instancia de UITableView después de que la vista se cargue inicialmente.

Ok, he estado tratando de solucionar un problema que obtuve por un par de días sin éxito. Hoy encontré una solución pero no una solución COMPLETA a mi problema.

Entonces este es el problema.

Comienza así, tenga en cuenta la alineación de las etiquetas de tiempo (las de la izquierda)

Pero después de que la mesa se recarga por segunda vez O cuando cambio las pestañas de un lado a otro, ENTONCES cambia a lo que quiero que se vea desde el principio. Me gusta esto.

Este es el código que hace esto dentro de cellForRowAtIndexPath:

if ([gameInfoObject.GameTime isEqual: @"FT"] || ([gameInfoObject.GameTime rangeOfString:@":"].location != NSNotFound)) { // CHeck to see if its FT or string contains ":" then hide liveB cell.liveButton.hidden = YES; CGRect frame = cell.gameTimeLabel.frame; frame.origin.x= 27; // move the label 10pts to the left since no image will be present cell.gameTimeLabel.frame= frame;

Encontré una solución de esta publicación Cambiando la posición de UIButton personalizado en UITableViewCell personalizado, pero el problema es que cambia PARA TODAS LAS CELDAS. Como puedes ver, solo necesito que cambie para algunas celdas. Por favor, ayúdenme, ¿qué puedo hacer sin ideas?

EDIT 1 todo el código para cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"Cell"; GamesInfoTableViewCell *cell = (GamesInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier]; // Configure the cell... GameInfo *gameInfoObject; gameInfoObject =[gamesInfoArray objectAtIndex:indexPath.row]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.backgroundColor = TABLECOLOR; cell.homeTeamLabel.textColor = TEXT; cell.awayTeamLabel.textColor = TEXT; cell.gameTimeLabel.textColor = TEXT; cell.homeTeamLabel.text = gameInfoObject.HomeTeam; cell.awayTeamLabel.text = gameInfoObject.AwayTeam; cell.homeTeamScoreLabel.text = gameInfoObject.HomeScore; cell.awayTeamScoreLabel.text = gameInfoObject.AwayScore; cell.liveButton.image = [UIImage imageNamed:@"1675447.png"]; //Load the green image if ([gameInfoObject.GameTime isEqual: @"FT"] || ([gameInfoObject.GameTime rangeOfString:@":"].location != NSNotFound)) { // CHeck to see if its FT or string contains ":" then hide liveB cell.liveButton.hidden = YES; CGRect frame = cell.gameTimeLabel.frame; frame.origin.x= 27; // move the label 10pts to the left since no image will be present cell.gameTimeLabel.frame= frame; } else cell.liveButton.hidden = NO; if (([gameInfoObject.GameTime rangeOfString:@":"].location != NSNotFound)) { cell.accessoryType = FALSE; cell.userInteractionEnabled = NO; cell.homeTeamScoreLabel.hidden = YES; cell.awayTeamScoreLabel.hidden = YES; } cell.gameTimeLabel.text = gameInfoObject.GameTime; return cell; }