在表视图中,我们通常加载几条记录(例如: 10条记录),然后如果用户想要更多记录,他会单击next按钮,在那里我们加载另外10条记录。
我希望用户下推最后一条记录,然后再加载另外10条记录,而不是单击一个按钮来加载下10条记录。看看pull To Refresh项目。在这种情况下,用户必须保持/拉取第一条记录一段时间以刷新页面。以类似的方式,我希望用户持有/拉出最后一条记录,以加载另外10条记录。
这个是可能的吗?我如何修改代码才能做到这一点呢?
重要事实:
1.)箭头图像应始终指向最后一条记录。2.)当用户按住图像时,应该加载另外10条记录,箭头图像现在应该在第21条记录(最后一条记录)上。
我如何通过编程来做到这一点呢?
发布于 2012-01-25 02:53:37
看起来像是一种奇怪的刷新方式,但为什么不:)
- (void)viewDidLoad {
[super viewDidLoad];
// Add a pinch gesture recognizer to the table view.
UIPinchGestureRecognizer* pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[self.tableView addGestureRecognizer:pinchRecognizer];
[pinchRecognizer release]; 处理它:
-(void)handlePinch:(UIPinchGestureRecognizer*)pinchRecognizer {
/*
There are different actions to take for the different states of the gesture recognizer.
* In the Began state, use the pinch location to find the index path of the row with which the pinch is associated, and keep a reference to that in pinchedIndexPath. Then get the current height of that row, and store as the initial pinch height. Finally, update the scale for the pinched row.
* In the Changed state, update the scale for the pinched row (identified by pinchedIndexPath).
* In the Ended or Canceled state, set the pinchedIndexPath property to nil.
*/
if (pinchRecognizer.state == UIGestureRecognizerStateBegan) {
[self updateForPinchScale:pinchRecognizer.scale atIndexPath:newPinchedIndexPath];
}
else {
if (pinchRecognizer.state == UIGestureRecognizerStateChanged) {
[self updateForPinchScale:pinchRecognizer.scale atIndexPath:self.pinchedIndexPath];
}
else if ((pinchRecognizer.state == UIGestureRecognizerStateCancelled) || (pinchRecognizer.state == UIGestureRecognizerStateEnded)) {
self.pinchedIndexPath = nil;
}
}
}
-(void)updateForPinchScale:(CGFloat)scale atIndexPath:(NSIndexPath*)indexPath {
if (indexPath && (indexPath.section != NSNotFound) && (indexPath.row != NSNotFound)) {
// make update here if indexpath == last index path
/*
Switch off animations during the row height resize, otherwise there is a lag before the user's action is seen.
*/
BOOL animationsEnabled = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[self.tableView beginUpdates];
// do any changes like inform user about download here
[self.tableView endUpdates];
[UIView setAnimationsEnabled:animationsEnabled];
}
}和vu a la
https://stackoverflow.com/questions/8990156
复制相似问题