정확하게 질문을 표현할 수 있을지 모르겠다. 자세한 내용은 여기에있다. UITableView를 사용하여 사용 가능한 글꼴 목록을 표시하고 있습니다. 목록을 표시하면 한 번에 약 12 행만 표시되므로 이전에 선택한 글꼴이 아직 표시되지 않으면 처음보기를 표시 할 때 선택할 수 없습니다.아직 표시되지 않은 UITableView 행을 선택하는 방법은 무엇입니까?
내가 원하는 것은 셀이 선택되어 있고보기가 나타날 때 목록 중앙에 표시하는 것입니다. 필요에 따라 jQuery과 만 데이터를로드,이 최고이기 때문에 그러나 나는 얻을 수 있습니다 :
이 편집 나는이 시도했지만 작동하지 않습니다 (셀이 간략하게 만 선택되어 스크롤하는 동안) :
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil){
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
[cell.textLabel setText:[fontArray objectAtIndex:indexPath.row]];
[cell.textLabel setFont:[UIFont fontWithName:[fontArray objectAtIndex:indexPath.row] size:16]];
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
//select the cell/row if it matches the current font
if([cell.textLabel.text isEqualToString:currentFontName]){
cell.selected=YES;
}
NSLog(@"returning cell %@",cell.textLabel);
return cell;
}
FWIW, 셀을 재사용하지 않으면 scrollls 끔찍한 테이블을 만드는 좋은 방법입니다. 셀이 다시 사용될 때 버그가 셀 상태를 다시 설정하지 않는 것 같습니다. – smparkes