2013-01-17 24 views

回答

0

如果您在Interface Builder中創建表或單元格,那麼在創建對象時,必須在Interface Builder中設置重用標識符,因爲此屬性被設置。 只有以編程方式創建整個對象而不是在Interface Builder中創建,才能以編程方式更改(更好:設置)。

0
static NSString *CellIdentifier = @"YourCellName"; 

YourCellName *cell = (YourCellName *) [tablview dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 

    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"YourCellName" owner:self options:nil]; 

    for (id currentObject in topLevelObjects){ 
     if ([currentObject isKindOfClass:[UITableViewCell class]]){ 
      cell = (YourCellName *) currentObject; 
      break; 
     } 
    } 
} 
+0

我做靜態的NSString * CellIdentifier = @ 「CustomCellForAlarm」; CustomCell * cell =(CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];如果(cell == nil) { NSLog(@「New」); NSArray * topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@「CustomCell」owner:self options:nil];如果([currentObject isKindOfClass:[UITableViewCell class]]){ cell =(CustomCell *)currentObject; 休息; } } } 新單元格創建wn滾動 – Durgaprasad

+0

對不起,我不明白 –

+0

我用你的方式,但它每次創建單元格。從xib我給了標識符,它的工作 – Durgaprasad

相關問題