Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何创建类似幻灯片的UIScrollView_Objective C_Ios - Fatal编程技术网

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为什么要重新发明轮子?