我有一个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