简体   繁体   English

使用 Three20 重新排序超出表格范围的行/单元格时,表格视图不会滚动

[英]Table view doesn't scroll when Reordering Rows/Cells beyond bounds of table using Three20

When I re-order rows/cells in my Three20 TTTableViewController (editing a table and moving individual cells up or down) it does not scroll with the cell being moved beyond the bounds of the tableview.当我在 Three20 TTTableViewController 中重新排序行/单元格(编辑表格并向上或向下移动单个单元格)时,它不会随着单元格的移动超出表格视图的边界而滚动。 When I do drag the cell up beyond the bounds it automatically animates the cell upwards and out of the view without scrolling with it.当我将单元格向上拖动超出边界时,它会自动将单元格向上动画并移出视图,而无需滚动它。 This makes it impossible to effectively re-order cells to positions outside of what is currently visible.这使得无法有效地将单元格重新排序到当前可见之外的位置。

I have tested this with and without Three20 and it only doesn't scroll the table when ordering with the Three20 implementation.我已经在使用和不使用 Three20 的情况下对此进行了测试,并且仅在使用 Three20 实现订购时不会滚动表格。

Apparently Three20's TTTableView implementation overrides UIScrollView 's显然 Three20 的TTTableView实现覆盖UIScrollView

- (void)setContentSize:(CGSize)size;

and

- (void)setContentOffset:(CGPoint)point;

These are meant to prevent the contentOffset from being changed incorrectly with a change in content size or height of the table, although it inadvertently prevents the table from scrolling when moving rows in editing mode.这些旨在防止 contentOffset 随着表格内容大小或高度的变化而被错误地更改,尽管它在编辑模式下移动行时无意中阻止了表格滚动。

I commented out these methods and the functionality I needed became available.我注释掉了这些方法,我需要的功能变得可用。

Three20 likes to control scrolling behavior with the setContentOffset and setContentSize method overrides. Three20 喜欢使用 setContentOffset 和 setContentSize 方法覆盖来控制滚动行为。 Scrolling behavior is controlled with a scrollEnabled property.滚动行为由 scrollEnabled 属性控制。

TTTableViews are scrollEnabled = YES, but at the time this method is called scrollEnabled = NO and needs to be reset when reordering rows. TTTableViews是scrollEnabled = YES,但是当时这个方法叫做scrollEnabled = NO,需要在重新排序行时重新设置。

  • (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath { tableView.scrollEnabled = YES; (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath { tableView.scrollEnabled = YES; } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM