按钮应该触发动作,直到我按住按钮

发布于 2024-12-07 06:52:00 字数 186 浏览 1 评论 0原文

我有 UIscrollview,其中放置了图像。我使用按钮(触摸向下)在滚动视图内将图像的位置移动 5 个像素……只有当我重复触摸按钮时,按钮才会触发操作(它会移动图像)如果我一次又一次触摸按钮,则为 5 像素)我希望按钮触发操作,直到我按住按钮(它应该移动图像,直到我释放按钮)...

是否有可能通过按钮滚动 UIscrollview点击?

I have UIscrollview in which I have placed images.I use the buttons(touch down) to move the position of the images by 5pixels inside the scroll view…..Button fires the action only if I repeatedly touches the buttons ( it moves the images to 5pixels if I touches the button again and again) I want my button to fire the action until I keep the button down (it should moves the images until I release the button)…

Is there any possibility to scroll the UIscrollview by means of button click?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绮筵 2024-12-14 06:52:00

您必须监听 TouchDown 和 TouchUp 事件。当触发 TouchDown 事件时,您将启动一个定期调用方法的计时器(或其他计时器),当您收到 TouchUp 事件时,您将停止它。

它可能看起来像这样:(

-(IBAction)touchDownAction:(id)sender
{
    self.yourtimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(aselector) userInfo:nil repeats:YES];
}

-(IBAction)touchUpAction:(id)sender
{
    if ([yourtimer isValid])
    {
        [yourtimer invalidate];
    }
}

您只需通过 IB 将您的按钮与这些方法链接起来)

You'll have to listen to the TouchDown and TouchUp events. When a TouchDown event is fired you start a timer (or other) that periodically calls a method, and when you receive a TouchUp event you stop it.

It might looks something like that:

-(IBAction)touchDownAction:(id)sender
{
    self.yourtimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(aselector) userInfo:nil repeats:YES];
}

-(IBAction)touchUpAction:(id)sender
{
    if ([yourtimer isValid])
    {
        [yourtimer invalidate];
    }
}

(You just have to link your button with these methods via IB)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文