我Mike_NotGuilty同意更換UITableViewCell
。我試了一下,他建議的UITableViewCell的我的自定義/子類,稱爲BNRItemCell與方法定義如下,它的偉大工程:
//This function is where all the magic happens
-(void) tableView:(UITableView *) tableView willDisplayCell:(BNRItemCell *) cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Set the cells background color
if (indexPath.row % 2 == 0) {
UIColor *altCellColor = [UIColor colorWithWhite:0.3 alpha:0.5];
cell.backgroundColor = altCellColor;
}
[UIView beginAnimations:@"fade" context:nil];
[UIView setAnimationDuration:20.0];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount: 0.5];
[cell.nameLabel setAlpha:0.4];
[cell.nameLabel setAlpha:1];
[UIView commitAnimations];
}
您應該與您的自定義一個替換原來的方法定義和嘗試:
-(void) tableView:(UITableView *) tableView willDisplayCell:(PostCell *) cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// your code here
}
您是否嘗試將您的細胞作爲您的自定義單元格?因爲該方法說「單元」是一個「UITableViewCell」。 – 2014-09-23 09:06:25
爲什麼不在'cellForRowAtIndexPath:'或者你的單元子類的'awakeFromNib'中做到這一點? – Andy 2014-09-23 09:59:46
因爲我聽說配置類型的東西應該在顯示方法 – 2014-09-23 10:17:14