[英]How to pause/disable UILongPressGestureRecognizer on a UITableViewCell while in editmode
在tableview中,我在每個單元格上都有一個UILongPressGestureRecognizer
,我這樣添加:
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(TableCellLongPressed:)];
longPress.minimumPressDuration = 0.5f;
[cell addGestureRecognizer:longPress];
[longPress release];
現在我確實有以下問題我希望用戶能夠重新排列tableview中的單元格,所以我有一個按鈕,將tableView設置為EditMode,如下所示:
[self.myTableView setEditing:!self.myTableView.editing animated:YES];
現在當用戶試圖拖動一個單元並且沒有將它拖得足夠遠時,longPress會激活他的動作,這對用戶來說非常煩人,導致另一個視圖被推動。 當tableView在EditMode中時,如何暫停或禁用UILongPressGestureRecognizer
?
您應該為此方法實現UIGestureRecognizerDelegate委托:
gestureRecognizer:shouldReceiveTouch:
在該方法中,檢查您是否正在編輯表,如果是,則返回NO。
蒂姆
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.