0
我正在使用UIPanGestureRecognizer
来允许我的UITableView
被拖动。我目前已将其设置为使UITableView
不能拖过0
或其一半宽度。但现在,当我尝试从大于0的原点将UITableView
拖回到0时,它的帧被设置为0.我怎样才能防止这种情况,并允许将UITableView
拖回0?我已经尝试了以下内容,但我无法完全弄清楚为什么轮廓代码导致这种情况。拖动UITableView
- (void) handlePan:(UIPanGestureRecognizer *) pan {
CGPoint point = [pan translationInView:_tableView];
CGRect frame = [_tableView frame];
if (point.x <= _tableView.frame.size.width/2) {
frame.origin.x = point.x;
}
NSLog(@"%f : %f", frame.origin.x, _tableView.frame.origin.x);
//outline begin!
if (frame.origin.x < 0 && _tableView.frame.origin.x >= 0) {
frame.origin.x = 0;
}
//outline end!
isFilterViewShowing = frame.origin.x > 0;
[_tableView setFrame:frame];
}
这实际上没有帮助,我尝试使用superView,但没有找到触摸。你能理解为什么我的代码不工作吗? –
不要在你的superView中寻找触摸,让pan在superView的坐标系中返回翻译CGPoint。 –
你能举个例子吗? –