ios - 触摸并向上移动手指 - 数字增加,向下移动 - 相反

标签 ios xcode

当您触摸屏幕并向上移动手指时,我不明白如何制作与应用程序中相同的系统(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/

相关文章:

ios - 带有 UIButton 的自定义 UITableView 单元不调用 didSelectRowAtIndexPath

iphone - 从 PDF 中提取图像

ios - 使用 UISegmentedControl 进行多项选择 - Pages 使用的是什么?

ios - 以正确的格式在控制台中显示 unicode

android - 如何在 Phonegap/Cordova 应用中返回 Google 登录/帐户选择器?

iphone - NSOperationQueue、weakSelf 和 block 的问题

ios - 将 iPad 连接到 Mac Mini 以进行 Xcode 开发

ios - 如何从 Firebase 获取按时间顺序排列的最新帖子?

应用程序中的 ios 路径问题缺少 libidn-1.15.tar.gz

ios - 无法打开文件“Cartfile”,因为没有这样的文件