gpt4 book ai didi

iphone - 如何将 IBAction 事件与图像相关联?

转载 作者:搜寻专家 更新时间:2023-10-30 20:07:38 26 4
gpt4 key购买 nike

我有一个包含动态图像的应用程序,我想使用我的自定义动画为图像设置动画。

如何将 IBAction 事件与图像相关联?

我如何检测屏幕上用户触摸图像的坐标?

请提出您的建议。

在此先致谢,非常欢迎您提出建议。

最佳答案

您可以对图像使用自定义 UIButton。所有触摸处理代码都已内置。


编辑:UIGestureRecognizer 也适用于 UIImageViews:

UIImageView *imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"foo.png"]] autorelease];
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)] autorelease];
[imageView addGestureRecognizer:tapGesture];
[self.view addSubview:imageView];

关于iphone - 如何将 IBAction 事件与图像相关联?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3922449/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com