在我的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. UITableViewCell中的UIGestureRecognizer
- 2. UITableViewCell內的UIView的UIGestureRecognizer
- 3. UIGestureRecognizer和UITableViewCell的問題
- 4. 添加UIGestureRecognizer到一個UITableViewCell
- 5. Swift Playgrounds中的UIGestureRecognizer
- 6. iOS 3.1.3中的UIGestureRecognizer?
- 7. 如何將UIGestureRecognizer添加到UITableViewCell子視圖?
- 8. `UIGestureRecognizer`命中測試
- 9. 的iOS UIGestureRecognizer
- 10. MPMoviePlayerViewController上的UIGestureRecognizer
- 11. UIScrollView上的UIGestureRecognizer
- 12. 的UITableViewController與UIGestureRecognizer
- 13. 的UIBarButtonItem和UIGestureRecognizer
- 14. iphone應用中的uigesturerecognizer
- 15. 覆蓋UIGestureRecognizer的touchesBegan
- 16. UIGestureRecognizer抵消的TargetView
- 17. 在UIWebView中使用UIGestureRecognizer
- 18. 在Swift中擴展UIGestureRecognizer
- 19. UIGestureRecognizer拖動UIView
- 20. UIGestureRecognizer部分UIView
- 21. UIGestureRecognizer結束
- 22. CCLayer UIGestureRecognizer和HUD
- 23. 繼承uigesturerecognizer iphone
- 24. NSLog UIGestureRecognizer描述?
- 25. UIGestureRecognizer關閉
- 26. Swift UIGestureRecognizer Touchdown
- 27. UIGestureRecognizer in objective-C++
- 28. UIGestureRecognizer和UISplitViewController
- 29. Write a Circular UIGestureRecognizer
- 30. CGPoint PreviousLocation - UIGestureRecognizer
您能否包含一些代碼?你處理滑動的方法會很好。 – jrturton 2012-01-02 12:00:40