1

UIWebView用作UIView从服务器加载动画图像(GIF)的子视图。

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

我将 Tap 手势添加到我的UIView,但 webView 禁用了这个手势(UIWebView frame=UIView Frame[view sendSubViewToBack:webView].

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

4

1 回答 1

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");
}
于 2013-01-20T02:08:57.260 回答