gpt4 book ai didi

ios - UIwebView 加载动画图像不响应 UITapGestureRecognizer

转载 作者:行者123 更新时间:2023-11-29 13:20:41 24 4
gpt4 key购买 nike

我使用 UIWebView 作为 UIView 的 subview 从服务器加载动画图像 (GIF)。

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:picLink]]];

然后我将 Tap 手势添加到我的 UIView,但是 webView 禁用了这个手势(UIWebView frame = UIView Frame[查看 sendSubViewToBack:webView]

如何解决?是否有另一种方法来显示 GIF 图像。谢谢!

最佳答案

您可以将同级 UIView 放在 UIWebView 之上,并将点击手势识别器添加到该同级。代码可能如下所示:

- (void)viewDidLoad {
[super viewDidLoad];

UIView *containerView = [[UIView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:containerView];

UIWebView *webView = [[UIWebView alloc] initWithFrame:containerView.bounds];
[containerView addSubview:webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://i.imgur.com/eezCO.gif"]]];

UIView *frontView = [[UIView alloc] initWithFrame:containerView.bounds];
[containerView addSubview:frontView];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[frontView addGestureRecognizer:tapRecognizer];
}

- (void)tapped:(UITapGestureRecognizer *)tapRecognizer {
NSLog(@"tapped");
}

关于ios - UIwebView 加载动画图像不响应 UITapGestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14420883/

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