我有一個tableVIew,其中每個單元格的高度爲90.0f(高度)。我的代碼;TableView單元格外觀問題
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 90.0;
}
現在,當我刪除表中的所有記錄。單元格的高度縮小到它的默認值44(我認爲)。
1.)我的問題是,即使在用戶刪除所有記錄後,我仍然需要單元格的高度保持爲90.0f。我如何以編程方式執行此操作?
2.)我給了我的細胞2種顏色。
cell.contentView.backgroundColor = indexPath.row % 2 ? [UIColor whiteColor] : [UIColor blackColor] ;
當我刪除第二個單元格,它是黑色的,那麼第一個和第三個單元格都是白色的。我怎麼能重新安排這是一個訂單黑色和白色。
編輯:
好這個工作,但是當我嘗試刪除表中的最後一個記錄和[tableview indexPathsForVisibleRows]
我最終得到斷言失敗
-[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:961
和
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. Attempt to delete more rows than exist in section.'
這是爲什麼?
CODE:
[self.tableView beginUpdates];
[self.myArray removeObjectsInArray:discardedItems ];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:YES];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:YES];
[self.tableView endUpdates];
你知道你可以使用blackColor而不是黑色寫出的RGB值。 – 2012-01-29 16:18:56
還有一些其他的顏色,我不得不改變它發佈到SO – sharon 2012-01-29 16:20:35