Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
add 3D touch to example
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinhope committed Jun 6, 2016
1 parent 260629f commit f2bb9c1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SwipeableTableViewCell/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.7</string>
<string>0.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion SwipeableTableViewCell/SwipeableTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class SwipeableTableViewCell: UITableViewCell, UIScrollViewDelegate {
lazy var longPressGesture: UILongPressGestureRecognizer = {
let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(SwipeableTableViewCell.scrollViewLongPressed(_:)))
longPressGesture.cancelsTouchesInView = false
longPressGesture.minimumPressDuration = 0.13
longPressGesture.minimumPressDuration = 0.16
return longPressGesture
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class BackgroundViewExampleViewController: UITableViewController {
return titleView
}()
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: switchView)

if #available(iOS 9, *) {
if traitCollection.forceTouchCapability == .Available {
registerForPreviewingWithDelegate(self, sourceView: view)
}
}
}

func pushSwitchValueChanged(sender: UISwitch) {
Expand Down Expand Up @@ -96,3 +102,20 @@ class BackgroundViewExampleViewController: UITableViewController {
}
}
}

@available(iOS 9.0, *)
extension BackgroundViewExampleViewController: UIViewControllerPreviewingDelegate {
func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
guard let indexPath = tableView.indexPathForRowAtPoint(location), cell = tableView.cellForRowAtIndexPath(indexPath) else {
return nil
}
let previewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ViewController")
previewController.preferredContentSize = CGSize.zero
previewingContext.sourceRect = cell.frame
return previewController
}

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {
showViewController(viewControllerToCommit, sender: self)
}
}
2 changes: 1 addition & 1 deletion SwipeableTableViewCellExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
<!--View Controller-->
<scene sceneID="DG7-EB-VKg">
<objects>
<viewController id="qmZ-UH-X6L" sceneMemberID="viewController">
<viewController storyboardIdentifier="ViewController" id="qmZ-UH-X6L" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="L9R-ek-Pqz"/>
<viewControllerLayoutGuide type="bottom" id="pi4-Iq-7VB"/>
Expand Down
4 changes: 2 additions & 2 deletions SwipeableTableViewCellExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.7</string>
<string>0.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>7</string>
<string>8</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down

0 comments on commit f2bb9c1

Please sign in to comment.