-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJS3DTouchTableViewController.swift
More file actions
52 lines (42 loc) · 2.04 KB
/
JS3DTouchTableViewController.swift
File metadata and controls
52 lines (42 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// JS3DTouchTableViewController.swift
// HardCast
//
// Created by Jann Schafranek on 10.04.17.
// Copyright © 2017 JSFun. All rights reserved.
//
import UIKit
class JS3DTouchTableViewController: UITableViewController, UIViewControllerPreviewingDelegate {
var previewingContext:UIViewControllerPreviewing?
var presentsComittedViewControllers:Bool = false
override func viewDidLoad() {
super.viewDidLoad()
self.previewingContext = self.registerForPreviewing(with: self, sourceView: self.tableView)
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
if let indexPath = self.tableView.indexPathForRow(at: location){
previewingContext.sourceRect = self.tableView.rectForRow(at: indexPath)
return self.tableView(self.tableView, peekViewControllerForRowAt: indexPath)
}
return nil
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
if presentsComittedViewControllers{
self.present(viewControllerToCommit, animated: true, completion: nil)
}else{
self.navigationController?.show(viewControllerToCommit, sender: nil)
}
}
func tableView(_ tableView: UITableView, peekViewControllerForRowAt indexPath: IndexPath) -> UIViewController? {
fatalError("tableView(tableView:, peekViewControllerForRowAt:) not implemented in JS3DTouchTableViewController subclass")
}
override func numberOfSections(in tableView: UITableView) -> Int {
fatalError("numberOfSections not implemented in JS3DTouchTableViewController subclass")
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
fatalError("numberOfRows not implemented in JS3DTouchTableViewController subclass")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}