在我的UITableViewCell中,我有UISwipeGestureRecognizer在单元格中滑动图像,并且卡住了。例如,GestureRecognizer调用方法,增加图像数量并重新加载行。如何定义被触摸的行并将其传递给方法?UITableViewCell中的UIGestureRecognizer
0
A
回答
1
我发现,我们可以通过触摸坐标定义swiped cell。它看起来像这样:
if (recognizer.state == UISwipeGestureRecognizerStateEnded) {
CGPoint gestureLocation = [recognizer locationInView:self.tableView];
NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:gestureLocation];
//found IndexPath for swiped cell. Now we can do anything what we need.
//In my case it's cell reloading with new image in UIImageView.
NSArray *rowsToReload = [[NSArray alloc] initWithObjects:swipedIndexPath, nil];
[self.tableView reloadRowsAtIndexPaths:rowsToReload withRowAnimation:UITableViewRowAnimationNone];
+0
你的if语句缺少结束括号,究竟应该去哪里? – 2012-09-19 15:16:34
0
也许您应该禁用单元格选择 - 通常会触发单元格重新加载。
相关问题
- 1. UIGestureRecognizer和UITableViewCell的问题
- 2. 添加UIGestureRecognizer到一个UITableViewCell
- 3. iOS 3.1.3中的UIGestureRecognizer?
- 4. Swift Playgrounds中的UIGestureRecognizer
- 5. 如何将UIGestureRecognizer添加到UITableViewCell子视图?
- 6. MPMoviePlayerViewController上的UIGestureRecognizer
- 7. 的UITableViewController与UIGestureRecognizer
- 8. iphone应用中的uigesturerecognizer
- 9. 覆盖UIGestureRecognizer的touchesBegan
- 10. UIGestureRecognizer抵消的TargetView
- 11. 在UIWebView中使用UIGestureRecognizer
- 12. 在Swift中扩展UIGestureRecognizer
- 13. 继承uigesturerecognizer iphone
- 14. UIGestureRecognizer和UISplitViewController
- 15. UIGestureRecognizer崩溃
- 16. Swift UIGestureRecognizer Touchdown
- 17. 确认UIGestureRecognizer?
- 18. UIGestureRecognizer in objective-C++
- 19. UIGestureRecognizer结束
- 20. Write a Circular UIGestureRecognizer
- 21. NSLog UIGestureRecognizer描述?
- 22. UIGestureRecognizer和UITextView
- 23. UIGestureRecognizer关闭
- 24. UIGestureRecognizer部分UIView
- 25. InterfaceBuilder中的UIGestureRecognizer目标/操作
- 26. UITableView中的UIGestureRecognizer - 滚动后崩溃?
- 27. 如何扩大UIGestureRecognizer的命中区域?
- 28. UIGestureRecognizer覆盖UITableViewController中的“长按”
- 29. 转换图层上的UIGestureRecognizer
- 30. UIGestureRecognizer商店在NSData
您能否包含一些代码?你处理滑动的方法会很好。 – jrturton 2012-01-02 12:00:40