当您触摸屏幕并向上移动手指时,我不明白如何制作与应用程序中相同的系统(https://itunes.apple.com/us/app/dgrees-celsius-fahrenheit/id707697403),然后数字会增加。
它看起来像 ScrollView 。也许我需要在 scrolling.scrolling 时计算 View 的 y.position。
最佳答案
您可以使用 UIPanGestureRecognizer , 然后使用 translationInView找出用户的手指移动了多少,并相应地更新您的 View
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];
}
关于ios - 触摸并向上移动手指 - 数字增加,向下移动 - 相反,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22794015/