Skip to content

Instantly share code, notes, and snippets.

@switz
Last active August 29, 2015 14:13
Show Gist options
  • Save switz/0bc0e75598ed4884cba5 to your computer and use it in GitHub Desktop.
Save switz/0bc0e75598ed4884cba5 to your computer and use it in GitHub Desktop.

Revisions

  1. switz revised this gist Jan 22, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions view.swift
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,8 @@ class ContainerViewController: UIViewController, UITableViewDelegate, NSFetchedR
    }
    if (gesture.state != UIGestureRecognizerState.Began) { return; }

    let tapLocation = gesture.locationInView(self.table);
    if let indexPath = self.table.indexPathForRowAtPoint(tapLocation) {
    let fingerLocation = gesture.locationInView(self.table);
    if let indexPath = self.table.indexPathForRowAtPoint(fingerLocation) {
    let container = self.fetchedResultsController?.objectAtIndexPath(indexPath) as NSManagedObject
    // do stuff with container
    self.performSegueWithIdentifier("show_player", sender: self);
  2. switz revised this gist Jan 22, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions view.swift
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@ class ContainerViewController: UIViewController, UITableViewDelegate, NSFetchedR
    // Play on touch down
    var td = UILongPressGestureRecognizer(target: self, action: "touchDown:")
    td.minimumPressDuration = 0;
    td.allowableMovement = 10000;
    self.table.addGestureRecognizer(td);
    }

  3. switz revised this gist Jan 22, 2015. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions view.swift
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,11 @@
    // in view did load

    class ContainerViewController: UIViewController, UITableViewDelegate, NSFetchedResultsControllerDelegate {
    override func viewDidLoad() {
    super.viewDidLoad()
    // Play on touch down
    var td = UILongPressGestureRecognizer(target: self, action: "touchDown:")
    td.minimumPressDuration = 0;
    self.table.addGestureRecognizer(td);
    }

    func touchDown(gesture: UIGestureRecognizer) {
    if (gesture.state == UIGestureRecognizerState.Ended) {
    @@ -19,4 +21,5 @@
    // do stuff with container
    self.performSegueWithIdentifier("show_player", sender: self);
    }
    }
    }
    }
  4. switz created this gist Jan 22, 2015.
    22 changes: 22 additions & 0 deletions view.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    // in view did load

    // Play on touch down
    var td = UILongPressGestureRecognizer(target: self, action: "touchDown:")
    td.minimumPressDuration = 0;
    self.table.addGestureRecognizer(td);

    func touchDown(gesture: UIGestureRecognizer) {
    if (gesture.state == UIGestureRecognizerState.Ended) {
    if self.playerViewController != nil {
    self.playerViewController!.dismissViewControllerAnimated(false, completion: nil);
    }
    }
    if (gesture.state != UIGestureRecognizerState.Began) { return; }

    let tapLocation = gesture.locationInView(self.table);
    if let indexPath = self.table.indexPathForRowAtPoint(tapLocation) {
    let container = self.fetchedResultsController?.objectAtIndexPath(indexPath) as NSManagedObject
    // do stuff with container
    self.performSegueWithIdentifier("show_player", sender: self);
    }
    }