UIView がプルアップ ビューとして機能している UIView 内に UITableView があります。ビューを画面の上下にドラッグし、ドラッグでビューを上に移動したいと思います。
UITableView部分に触れている場合は、UIViewが上限に達するまでドラッグしてから、ドラッグしてUITableViewのドラッグを開始したいと思います。
UIView が上限にあり、UITableView を下にドラッグする場合、UITableView を最初に到達するまで下にドラッグしてから、ドラッグを UIView に転送し、それを UITableView と共に画面の下にドラッグします.
さらに、UITableVIew には、プレスに反応し続ける必要があるボタンがあるため、必要なときにテーブルビューのユーザー対話機能を単純にオフにすることはできません。
現在、UIView が一番上の駐車位置にあるときにフラグを設定し、拡張された UITableView クラスで次のメソッドを使用しています
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint then = [[touches anyObject] previousLocationInView: self];
CGPoint now = [[touches anyObject] locationInView: self];
//CGFloat deltaY = fabs(then.y - now.y);
if(self.contentOffset.y == 0 && now.y > then.y)
inSlideMode_ = YES;
if(inSlideMode_)
{
[self.nextResponder touchesMoved:touches withEvent:event];
}
else
{
[super touchesMoved:touches withEvent:event];
}
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint then = [[touches anyObject] previousLocationInView: self];
CGPoint now = [[touches anyObject] locationInView: self];
//CGFloat deltaY = fabs(then.y - now.y);
if(self.contentOffset.y == 0 && now.y > then.y)
inSlideMode_ = YES;
if (inSlideMode_)
{
//forwarding action:
[self.nextResponder touchesBegan:touches withEvent:event];
}
else
{
[super touchesBegan:touches withEvent:event];
}
}
-( void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if(inSlideMode_)
{
[self.nextResponder touchesEnded:touches withEvent:event];
}
else
{
[super touchesEnded:touches withEvent:event];
}
previousTouchY_ =UNTOUCHED_Y_POSITION;
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.y <= 0)
{
self.scrollEnabled = NO; // if we reach the top of scrolling then should switch tableview into the pullup interactor
self.inSlideMode = YES;
}
}
UIView 拡張クラスでは、同じメソッドをオーバーライドしてドラッグを処理し、ドラッグが上部にドッキングされているかどうかも確認しています。
現在はほとんど機能していますが、UITableView をドラッグすると、一番下に到達したら、指を離して再度ドラッグを開始し、UIView を下にドラッグする必要があります。助言がありますか???ありがとう