2009-12-06 3 views
1

테이블보기를 사용하여 목록을 표시하고 있습니다. 하나의 셀에만 UITableViewCellStyleValue1이 있습니다. 문제는 위/아래로 스크롤 할 때 세부 텍스트가 잘 표시되지 않는다는 것입니다. 여기에 코드가 있습니다.테이블 뷰 셀 스타일 문제 - UITableViewCellStyleValue1

 
    // Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
    if(indexPath.row == 0) 
    { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 
    cell.textLabel.textColor = [UIColor whiteColor]; 
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
    cell.detailTextLabel.textColor = [UIColor yellowColor]; 
    cell.detailTextLabel.text = @"Description"; 
    } 
    else 
    { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    cell.textLabel.textColor = [UIColor whiteColor]; 
    cell.accessoryType = UITableViewCellAccessoryNone; 
    } 
    } 

// Configure the cell. 
cell.textLabel.text = [radioList objectAtIndex:indexPath.row]; 
    return cell; 
} 

나를 도와 줄 수 있습니까?

답변

3

셀 재사용을 올바르게 처리하지 못합니다. 이것을 대신 해보면 내가하는 일을 다르게 볼 수있을 것이라고 생각합니다.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = nil; 
    if(indexPath.row == 0) 
    { 
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; 
    if (cell == nil) 
    { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier2] autorelease]; 
    } 
    cell.textLabel.textColor = [UIColor whiteColor]; 
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
    cell.detailTextLabel.textColor = [UIColor yellowColor]; 
    cell.detailTextLabel.text = @"Description"; 
    } 
    else 
    { 
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 
    cell.textLabel.textColor = [UIColor whiteColor]; 
    cell.accessoryType = UITableViewCellAccessoryNone; 
    } 
} 

// Configure the cell. 
cell.textLabel.text = [radioList objectAtIndex:indexPath.row]; 
return cell; 
} 
+0

답장을 보내 주셔서 감사합니다. –

관련 문제