3
A
答えて
4
私はカスタムセグエとスワイプジェスチャー認識で「右スワイプに左」とセグエを実現しています。
新しい.swiftファイルを作成し、インターフェイスビルダーのプロパティでsegueをクラスとして使用する必要があります。ご希望のViewController.swift内部で呼び出さ
import Foundation
import UIKit
//
// UISwipeGestureRecognizer.h
// UIKit
//
// Copyright (c) 2009-2015 Apple Inc. All rights reserved.
//
// Recognizes: when numberOfTouchesRequired have moved mostly in the specified direction, enough to be considered a swipe.
// a slow swipe requires high directional precision but a small distance
// a fast swipe requires low directional precision but a large distance
// Touch Location Behaviors:
// locationInView: location where the swipe began. this is the centroid if more than one touch was involved
// locationOfTouch:inView: location of a particular touch when the swipe began
public struct UISwipeGestureRecognizerDirection : OptionSetType {
public init(rawValue: UInt)
public static var Right: UISwipeGestureRecognizerDirection { get }
public static var Left: UISwipeGestureRecognizerDirection { get }
public static var Up: UISwipeGestureRecognizerDirection { get }
public static var Down: UISwipeGestureRecognizerDirection { get }
}
@available(iOS 3.2, *)
public class UISwipeGestureRecognizer : UIGestureRecognizer {
public var numberOfTouchesRequired: Int // default is 1. the number of fingers that must swipe
public var direction: UISwipeGestureRecognizerDirection // default is UISwipeGestureRecognizerDirectionRight. the desired direction of the swipe. multiple directions may be specified if they will result in the same behavior (for example, UITableView swipe delete)
}
によって:
private var swipeGestureRecognizer: UISwipeGestureRecognizer?
override func viewDidLoad() {
super.viewDidLoad()
swipeGestureRecognizer = MySwipeGestureRecognizer(target: self, swipeLeftSegue: "yourSwipeLeftSegue", swipeRightSeque: "yourSwipeRightSegue")
view.addGestureRecognizer(swipeGestureRecognizer!)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "yourSwipeLeftSegue" {
//your code goes here
}
}
// Created by David Seek on 25.04.16.
// Copyright © 2016 David Seek. All rights reserved.
//
import UIKit
class FromLeftToRightSegue: UIStoryboardSegue {
override func perform() {
let firstVC = self.sourceViewController.view as UIView!
let secondVC = self.destinationViewController.view as UIView!
let screenWidth = UIScreen.mainScreen().bounds.size.width
let screenHeight = UIScreen.mainScreen().bounds.size.height
secondVC.frame = CGRectMake(-screenWidth, 0, screenWidth, screenHeight)
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(secondVC, aboveSubview: firstVC)
// Animate the transition.
UIView.animateWithDuration(0.3, animations: {() -> Void in // set animation duration
firstVC.frame = CGRectOffset(firstVC.frame, 0.0, 0.0) // old screen stay
secondVC.frame = CGRectOffset(secondVC.frame, screenWidth, 0.0) // new screen strave from left to right
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController as UIViewController,
animated: false,
completion: nil)
}
}
}
スワイプジェスチャー認識装置はまた、新しい.swiftファイルに入力する必要がありますあなたに質問があるなら、これがあなたのために働くことを願って、私に知らせてください。
+0
うわあ、これはまさに私が探しているものです、あなたの助けに感謝:) –
+0
あなたは大歓迎です –
関連する問題
- 1. スワイプのジェスチャー方向を検出する方法は?
- 2. MPMoviePlayerViewControllerのスワイプ・ダウン・ジェスチャー
- 3. 条件付きセグの実行方法
- 4. Chromeで右スワイプの右ジェスチャーをプログラム的に無効にするにはどうすればよいですか?
- 5. 特定のシーンでcocos2dでジェスチャーを実行する方法
- 6. 3指のスワイプのジェスチャー
- 7. FBSessionDelegateメソッドでセグを実行する方法は?
- 8. ジェスチャーを複数のビューに持つVIEW(ダブルクリック、左スワイプ、右スワイプなど)を決定しますか?
- 9. UIViewをタップしてセグを実行する方法
- 10. スウィフトでのログイン後のスワイプ・ジェスチャー
- 11. 2本の指でスワイプのジェスチャー
- 12. ネットワーク接続に応じてセグを実行する方法は?
- 13. SWTableViewCellでスワイプ右選択オプションを追加する方法
- 14. 条件が真である場合にのみセグを実行する方法
- 15. python kivy appで左右にスワイプする方法は?
- 16. デリゲートメソッドからセグを実行
- 17. Flex viewNavigatorとスワイプ:ジェスチャーと効果的なスワイプの間の遅延
- 18. スワイプでのゼロフィル右シフト
- 19. RideRequestButtonを押したときにバックグラウンドでセグを実行する方法は?
- 20. カスタムキーボードの左右のスペースキーをスワイプでキーボードレイアウトを変更する方法
- 21. tmap talendで右結合を実行する方法DI
- 22. ジェスチャーでタブコントロールをスワイプ/フリップ/スライドできますか?
- 23. UITABLEVIEWをスワイプで右にスワイプしたときのアクションを追加
- 24. appiumのためにアンドロイドで垂直スワイプを実行する方法
- 25. UITableViewCellのジェスチャーをUITableViewCellで実行し、ジェスチャーの最後にアクションを実行します。
- 26. コレクションビューからテーブルビュー内のセグを実行
- 27. jQueryでAndroidのキャンセル/バックスワイプ(スワイプを左から右にスワイプ)
- 28. XamarinをスワイプするときにCarouselViewで左右にスワイプを無効にする
- 29. ギャラリーのスワイプをドットで実装する方法
- 30. GridViewで左にスワイプして右にスワイプします
ユーザーが画面の端からスワイプしたときにセグエを発生させたい場合は、[UIScreenEdgePanGestureRecognizer](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreenEdgePanGestureRecognizer_class/#)を参照してください。 // apple_ref/occ/instp/UIScreenEdgePanGestureRecognizer/edges)。 –