gpt4 book ai didi

objective-c - 如何让 imageview 做一个 segue

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:19:00 26 4
gpt4 key购买 nike

我在 GridView 中生成了一堆 ImageView 。但现在我希望每个 imageview 都可以对另一个屏幕进行 segue。有人知道我该怎么做吗?这是我如何生成 ImageView 并将其放入网格的代码。

UIImageView * myView = [[UIImageView  alloc] initWithImage:myImage];
CGRect rect = myView.frame;
rect.origin.x = xCurrent;
rect.origin.y = yCurrent;
myView.frame = rect;
myView.tag = cellCounter;
[gridContainerView addSubview:myView];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];

myView.userInteractionEnabled = YES;

[myView addGestureRecognizer:tap];

请帮忙

亲切的问候

最佳答案

您正在寻找 tapGestureRecognizer。将其中一个添加到您的 ImageView 中,并使操作调用您的 segue 方法。

UIImageView *img = [[UIImageView alloc] init];

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mySequeMethod:)];

img.userInteractionEnabled = YES;

[img addGestureRecognizer:tap];

关于objective-c - 如何让 imageview 做一个 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12741732/

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