0
我想滑动我的看法像元素滑动UIScrollView
。用户可以触摸查看和拉动,并且根据加速度和位置,视图应该离开或停留。如何创建像UIScrollView幻灯片
我是否应该使用UIPanGestureRecognizer
和UISwipeGestureRecognizer
?
我想滑动我的看法像元素滑动UIScrollView
。用户可以触摸查看和拉动,并且根据加速度和位置,视图应该离开或停留。如何创建像UIScrollView幻灯片
我是否应该使用UIPanGestureRecognizer
和UISwipeGestureRecognizer
?
你想用UIPanGestureRecognizer,如果你想要的内容按照用户的手指(听起来像你在这里做的)。滑动手势将等待滑动完成,然后告诉你。
使用“状态”属性获取手指在启动时的位置,以及完成时的位置,并使用速度确定加速度。
CGPoint location = [sender locationInView:self.view];
if(sender.state == UIGestureRecognizerStateBegan)
{
startLocation = location;
}
else if(sender.state == UIGestureRecognizerStateChanged)
{
// Move view or do something to give feedback to user while they swipe
}
else if(sender.state == UIGestureRecognizerStateEnded)
{
CGPoint distanceMoved = CGPointMake(location.x - startLocation.x, location.y - startLocation.y);
CGPoint velocity = [sender velocityInView:self.view];
// Logic goes here
}
'UIPanGestureRecognizer' – atxe
使用的UIScrollView为什么重新发明轮子? – jithinroy