-2

您好,我正在尝试添加一个水龙头来启动图像,就像在飞扬的小鸟中一样,但我真的无法在网上找到我要寻找的东西,所以我来到了这里。我曾尝试使用 UIImageView 来执行此操作,但它不起作用。

有谁知道如何做到这一点?

4

2 回答 2

1

您可以通过这种方式完成此任务。当您添加图像时,在 imageView 上添加一个透明按钮,然后从按钮的操作开始活动。

透明按钮代码

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
于 2014-03-15T18:45:49.243 回答
0

将 UITapGestureRecognizer 添加到 UIImageView 并将 UIImageView 的 userInteractionEnabled 设置为 YES。

尝试这个

imageView.userInteractionEnabled = YES;

UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped)];
[imageView addGestureRecognizer:tapGesture];
[tapGesture release];

并实施这个

- (void)viewTapped:(UITapGestureRecognizer *)gestureRecognizer
{
    UIView *tappedView = gestureRecognizer.view;
}
于 2014-03-19T10:24:17.687 回答