UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Preventing master view 'sliding in' from left on right swipe gesture

Forums > iOS

I've got a UISplitViewController, but I don't want the master view 'sliding in' from the left edge of the screen when user makes a left to right swipe gesture, as I want that gesture to be exclusively used for drawing actions on a UIImageView canvas that's in the detail view controller.

I've got this code in the viewDidLoad of the detail view controller class:

let right = UISwipeGestureRecognizer(target : AppDelegate(), action : #selector(AppDelegate.rightSwipe))
right.direction = .right
self.wordImage.addGestureRecognizer(right)

and in my appDelegate class I've got:

@objc func rightSwipe(){
    guard let splitViewController = self.window?.rootViewController as? UISplitViewController else {
        fatalError("Missing SplitViewController")
    }    
    splitViewController.preferredDisplayMode = .primaryHidden
}

I can swipe left to right in the canvas and it will draw a line and not slide in the master view controller (as I intended). However, the line drawing of the user's gesture only lasts a short distance until the line drawing stops. I can make an upwardish movement and draw, say, an 'S' curve and just keep on draweing, with no problem. The problem only seems to manifest when I'm making an absolutley straight line from with a left to right swipe gesture.

3      

In your split view controller, set presentsWithGesture = false.

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.