【发布时间】:2012-03-07 08:35:57
【问题描述】:
我已经完成了:
[tableView setNeedsLayout] 和 [tableView setNeedsDisplay],但是这不会调用该委托。有没有办法在不重新加载数据的情况下重新布局tableView(即:调用reloadData)
【问题讨论】:
标签: iphone objective-c ios ipad
我已经完成了:
[tableView setNeedsLayout] 和 [tableView setNeedsDisplay],但是这不会调用该委托。有没有办法在不重新加载数据的情况下重新布局tableView(即:调用reloadData)
【问题讨论】:
标签: iphone objective-c ios ipad
试试:
[tableView beginUpdates];
//do stuff...
[tableView endUpdates];
【讨论】:
您的需求究竟是什么。那么只有我们才能帮助您。
您是否执行过以下步骤来启动 UITableView 的委托
1.包括 UITableViewDelegate 和 UITableViewDataSource 2.将您的 tableViewDelegate 和数据源链接到 Interface Builder 中的 Files Owner
如果你想调用你的 tableview 委托方法意味着,
[table reloadData]
想知道您是否需要进一步说明
【讨论】:
这里列出了您可以用来仅影响表的一部分的方法。
插入、删除和移动行和节:
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
重新加载:
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
- (void)reloadSectionIndexTitles;
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
别忘了把你的代码放进去
[tableView beginUpdates];
//do stuff...
[tableView endUpdates];
按照@Wise Shepherd 的建议阻止,以避免tableView 的失禁状态和index out of bounds 异常。
【讨论】: