1

サーバーからアニメーション画像(GIF)をロードUIWebViewするためのサブビューとして使用します。UIView

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

そして、タップジェスチャをに追加しまし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 に答える