我使用UIWebView
作为UIView
的子视图来从服务器加载动画图像(GIF)。
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:picLink]]];
我将点按手势添加到UIView
,但是webView会停用此手势(UIWebView frame
= UIView Frame
和[view sendSubViewToBack:webView]
。
如何解决?是否有另一种显示GIF图像的方法。谢谢!
答案 0 :(得分:1)
您可以将兄弟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");
}