こんにちは、すべてを検索しましたが、これがわかりませんでした!
5 つのナビゲーション コントロールを備えたタブ バー コントローラーがあり、ナビゲーション コントロールの 1 つに、内部にテーブル ビューがあるビューがあり、その項目をクリックすると新しいビューがプッシュされ、そのビューには
view
-webview
-view
ツールバーとナビゲーションバーを非表示にするためにシングルタップを処理する必要があり、webview がすべてのタッチを食べていたため、2 番目のビュー (透明) を作成します。そのビューを配置し、View Controller に実装します
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch* touch = [touches anyObject];
if(touch.tapCount == 2){
[NSObject cancelPreviousPerformRequestsWithTarget:self];
}
[[wv.subviews objectAtIndex:0] touchesBegan:touches withEvent:event];
[super touchesBegan:touches withEvent:event];
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[[wv.subviews objectAtIndex:0] touchesMoved:touches withEvent:event];
[super touchesMoved:touches withEvent:event];
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch* touch = [touches anyObject];
if(touch.tapCount == 1){
[self performSelector:@selector(hideBars) withObject:nil afterDelay:0.3];
}
[[wv.subviews objectAtIndex:0] touchesEnded:touches withEvent:event];
[super touchesEnded:touches withEvent:event];
}
-(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
[[wv.subviews objectAtIndex:0] touchesCancelled:touches withEvent:event];
[super touchesCancelled:touches withEvent:event];
}
wv は私の UIWebView IBOutlet であり、コントローラーでタッチを取得して Web ビューに送信できるようになりました。すべてが機能していると思ったので、スクロールできますが、リンクがあるとクリックできません。そして、webview は、私がそのテストを行ったリンクを検出しています。リンクに触れるためにこれを実装する他の方法はありますか、またはこの回避策を変更してツールバーを非表示にし、webview を完全に機能させる必要がありますか? 事前に助けてくれてありがとう。