当你触摸屏幕并向上移动手指时,我不明白如何在app(https://itunes.apple.com/us/app/dgrees-celsius-fahrenheit/id707697403)中创建相同的系统,然后数字会增加。
看起来像滚动视图。也许我需要在scrolling.scrolling时计算y.position of view。
答案 0 :(得分:2)
您可以使用UIPanGestureRecognizer,然后使用translationInView查看用户的手指移动了多少,并相应地更新您的观看次数
UIPanGestureRecognizer* pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[self.view addGestureRecognizer:pan];
处理它:
-(void)handlePan:(UIPanGestureRecognizer*)sender
{
CGFloat yMovement = [sender translationInView:sender.view].y;
// Do something with the movement
// Then reset the translation
[sender setTranslation:CGPointZero inView:sender.view];
}