Objective c 如何创建类似幻灯片的UIScrollView
我想滑动我的视图,就像元素在Objective c 如何创建类似幻灯片的UIScrollView,objective-c,ios,Objective C,Ios,我想滑动我的视图,就像元素在UIScrollView中滑动一样。用户可以触摸视图和拉动,根据加速度和位置,视图应该离开或停留 我是否应该将uipangestureerecognizer与uisweegestureerecognizer一起使用 如果您想让内容跟随用户的手指(听起来像您在这里做的那样),您需要使用uipangestureerecognizer。滑动手势将等待滑动完成,然后告诉您 使用“状态”属性获取手指开始和结束时的位置,并使用速度确定加速度 CGPoint location=[s
UIScrollView
中滑动一样。用户可以触摸视图和拉动,根据加速度和位置,视图应该离开或停留
我是否应该将
uipangestureerecognizer
与uisweegestureerecognizer
一起使用 如果您想让内容跟随用户的手指(听起来像您在这里做的那样),您需要使用uipangestureerecognizer。滑动手势将等待滑动完成,然后告诉您
使用“状态”属性获取手指开始和结束时的位置,并使用速度确定加速度
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
}
UIPangestureRecognitor
使用UIScrollView为什么要重新发明轮子?