htmlページをスワイプするにはどうすればいいですか?スワイプhtml pages水平スワイプした場合の別のhtmlページ
0
A
答えて
0
UIWebViewはタッチで貪欲であり、すべてを処理したいので、Webビューでジェスチャーを処理するのは難しいです。
いつものようにWebビューでは、Javascriptですべてを試してみることができます。これについてはS.O. postでお読みください。
Iは(ズーム)を挟持し、ただし以下れるウェブビューにスワイプ処理好む方法:
サブクラス
UIWindow
:@interface MyWebNavigatorWindow : UIWindow {
のようにそのウィンドウ・タイプのインスタンスをインストールあなたのアプリのウィンドウ
application:didFinishLaunchingWithOptions
:_window = [[MyWebNavigatorWindow alloc] initWithFrame:rect];
また、Interface Builderでウィンドウオブジェクトにクラスを割り当てることもできます。あなたの
MyWebNavigatorWindow
クラスのsendEvent
でハンドルスワイプやピンチ:
- (void)sendEvent:(UIEvent*)event { NSSet* allTouches = [event allTouches]; UITouch* touch = [allTouches anyObject]; UIView* touchView = [touch view];
あなたはタッチがあなたのWebビューの内部で発生したときに検出する
sendEvent
機構が必要になります。私の場合、私は、私はタッチを処理するすべてのビューを「登録」して、タッチがそれらの内側にあるかどうかを確認:for (UIView* view in self.controlledViews) { // self.controlledViews is the array of all "registered" views if ([touchView isDescendantOfView:view]) {
、私はどのようなジェスチャーのそれを検出するために、様々なタッチのフェーズを処理します(コードスニペットコンパイルではないが、それはアイデアを与える)である:
if (touch.phase == UITouchPhaseBegan) { NSLog(@"TOUCH BEGAN"); _initialView = touchView; startTouchPosition1 = [touch locationInView:self]; startTouchTime = touch.timestamp; if ([allTouches count] > 1) { startTouchPosition2 = [[[allTouches allObjects] objectAtIndex:1] locationInView:self]; previousTouchPosition1 = startTouchPosition1; previousTouchPosition2 = startTouchPosition2; } } if (touch.phase == UITouchPhaseMoved) { NSLog(@"TOUCH MOVED"); if ([allTouches count] > 1) { CGPoint currentTouchPosition1 = [[[allTouches allObjects] objectAtIndex:0] locationInView:self]; CGPoint currentTouchPosition2 = [[[allTouches allObjects] objectAtIndex:1] locationInView:self]; CGFloat currentFingerDistance = CGPointDist(currentTouchPosition1, currentTouchPosition2); CGFloat previousFingerDistance = CGPointDist(previousTouchPosition1, previousTouchPosition2); if (fabs(currentFingerDistance - previousFingerDistance) > ZOOM_DRAG_MIN) { NSNumber* movedDistance = [NSNumber numberWithFloat:currentFingerDistance - previousFingerDistance]; if (currentFingerDistance > previousFingerDistance) { NSLog(@"zoom in"); [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_ZOOM_IN object:movedDistance]; } else { NSLog(@"zoom out"); [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_ZOOM_OUT object:movedDistance]; } } } } if (touch.phase == UITouchPhaseEnded) { CGPoint currentTouchPosition = [touch locationInView:self]; // Check if it's a swipe if (fabsf(startTouchPosition1.x - currentTouchPosition.x) >= SWIPE_DRAG_HORIZ_MIN && fabsf(startTouchPosition1.x - currentTouchPosition.x) > fabsf(startTouchPosition1.y - currentTouchPosition.y) && touch.timestamp - startTouchTime < 0.7 ) { // It appears to be a swipe. if (startTouchPosition1.x < currentTouchPosition.x) { NSLog(@"swipe right"); [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_SWIPE_RIGHT object:touch]; } else { NSLog(@"swipe left"); [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_SWIPE_LEFT object:touch]; } } startTouchPosition1 = CGPointMake(-1, -1); _initialView = nil; }
関連する問題
- 1. セルと水平スクロールのスワイプの競合
- 2. wp7水平スワイプ選択
- 3. ナビゲータのスワイプと水平ListViewのスクロールを同じページで
- 4. jquery mobileで別のHTMLページにスワイプする方法
- 5. 水平スクロールビューからコアデータオブジェクトをスワイプ
- 6. 水平アラインメントイメージhtml
- 7. HTML水平ロールバー
- 8. ページコントロールのサポートで水平スワイプの画面を作る方法
- 9. 水平スクロールHTML Webページを避ける
- 10. 水平スクロールビューで1回のスワイプで一定量スクロール
- 11. シーンの水平スワイプを無効にする
- 12. HTML水平線HR
- 13. HTMLリストの水平スクロール
- 14. css/HTMLの水平メニュー
- 15. モバイルでdivでスワイプ可能な水平スクロール
- 16. UITableViewスワイプを水平ページスワイプと一緒に削除する方法
- 17. Android NestedScrollViewを親に水平スワイプを渡す
- 18. HTML/CSSを使用した水平線
- 19. スワイプでボタンを押した場合の書き込み方法
- 20. UIWebviewは別のUIWebiewにスワイプ
- 21. HTMLディビジョン、列、水平スクロールバー
- 22. Tumblrの水平ナビゲーションバーの問題(CSS/HTML)
- 23. UITABLEVIEWをスワイプで右にスワイプしたときのアクションを追加
- 24. Input.GetAxis( "Horizontal")を使ってUnityの水平スワイプを検出できますか?
- 25. 複数のUICollectionViewにヘッダーを付けて水平にスワイプする方法
- 26. GWTページ/パネル間をスワイプ
- 27. iPhone上の同じHTML要素のスワイプとパン動作
- 28. スワイプ
- 29. カードdiv用のHTML水平スクロールバー
- 30. HTMLとCSSの水平調整