0
iOS 개발을 처음 사용합니다. 동적 높이 tableView 사용하고 있습니다. tableViewCell의 높이가 증가하거나이 코드를 사용하고 이에 대한 클릭에 감소 ... tableViewCell 높이의 UILabel 높이 조절
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self.selectedPath isEqual:indexPath])
{
return 250;
}
else
{
return 44;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
onSelectCount++;
self.selectedPath = indexPath;
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation: UITableViewRowAnimationLeft];
self.selectedRowIndex = [NSNumber numberWithInteger:indexPath.row];
[self.tableView1 deselectRowAtIndexPath:indexPath animated:YES];
//First we check if a cell is already expanded.
//If it is we want to minimize make sure it is reloaded to minimize it back
if(onSelectCount==1)
{
NSLog(@"num=%d",onSelectCount);
NSLog(@"First Condition");
[tableView beginUpdates];
NSIndexPath *previousPath = [NSIndexPath indexPathForRow:self.selectedRowIndex.integerValue inSection:0];
self.selectedRowIndex = [NSNumber numberWithInteger:indexPath.row];
self.selectedPath=indexPath;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:previousPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
}
if(self.selectedPath.row!=indexPath.row)
{
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:selectedPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
selectedPath=indexPath;
onSelectCount=0;
[self tableView:tableView didSelectRowAtIndexPath:selectedPath];
}
if(self.selectedRowIndex.integerValue == indexPath.row && onSelectCount==2)
{
[tableView beginUpdates];
self.selectedRowIndex = [NSNumber numberWithInteger:-1];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
onSelectCount=0;
[tableView endUpdates];
}
}
지금 나는 tableViewCell에 대한 몇 가지 정보를 표시하는 일부 레이블을 추가 할하지만 난 셀을 클릭 할 때 크기가 조절 완벽하게하지만 셀의 레이블은 크기가 조정되지 않습니다. 셀 높이를 사용하여 UILabels의 크기를 조정할 수있는 방법을 알려주십시오. 어떤 도움을 주시면 감사하겠습니다 ...