2014-02-17 2 views

답변

1

문제는이 함께 .. 난 당신이 타입 캐스팅을 할 것 같아요 ..

1

결정은 내가 믿는 간단하지만 나는 그것을 해결하는 방법을 모른다 당신이 (CustomDetailCell *)로 셀을 던져하지만 저장 유형이 여전히 UITableViewCell

무엇 당신이 할 수있는 것은 :

switch (indexPath.section) { 
case DetailControllerAddressSection: { 
    NSString *address = [self addressText]; 
    UITableViewCell *cell; 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
     if (IS_OS_7_OR_LATER) { 
      CustomDetailCell *detailCell = (CustomDetailCell *) [tableView dequeueReusableCellWithIdentifier:@"AddressCell" forIndexPath:indexPath]; 
      detailCell.mainLabel.text = address; 
      detailCell.detailLabel.text = [self distanceMessageForObjectData:self.objectData]; 
      cell = detailCell; 

     } else { 
      UniversalAddressCell *universalCell = (UniversalAddressCell *) [tableView dequeueReusableCellWithIdentifier:@"UniversalAddressCell" forIndexPath:indexPath]; 
      universalCell.backgroundView = [self cellBackgroundImageView:indexPath]; 
      universalCell.mainLabel.text = address; 
      cell = universalCell; 
1

두 셀에 대해 서로 다른 NIB가있는 경우 :

static NSString * simpleTableIdentifier = @ "SimpleTableCell";

SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 
if (cell == nil) 
{ 
    switch (indexPath.section) { 
     case DetailControllerAddressSection: 
     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell1" owner:self options:nil]; 
     cell1 = [nib objectAtIndex:0]; 
     // write here cell1 specific 
     cell=cell1; 
     break; 
     case anotherCase: 
     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell2" owner:self options:nil]; 
     cell2 = [nib objectAtIndex:0]; 
     // write here cell2 specific 
     cell=cell2; 

    } 
} 


return cell; 
관련 문제