【问题标题】:UIwebView load animation image not respond to UITapGestureRecognizerUIwebView 加载动画图像不响应 UITapGestureRecognizer
【发布时间】:2013-01-20 01:41:36
【问题描述】:

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

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

我在UIView 中添加了点击手势,但 webView 禁用了这个手势(UIWebView frame = UIView Frame[view sendSubViewToBack:webView]

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

【问题讨论】:

标签: ios objective-c uiview uiwebview


【解决方案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");
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-23
    • 2012-12-22
    • 2011-11-10
    • 2011-09-01
    • 2021-11-30
    • 1970-01-01
    • 2016-03-31
    相关资源
    最近更新 更多