-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ivanbruel/ForceTouchable
- Loading branch information
Showing
1 changed file
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# ForceTouchable | ||
|
||
[![CI Status](http://img.shields.io/travis/Ivan Bruel/ForceTouchable.svg?style=flat)](https://travis-ci.org/Ivan Bruel/ForceTouchable) | ||
[![Version](https://img.shields.io/cocoapods/v/ForceTouchable.svg?style=flat)](http://cocoapods.org/pods/ForceTouchable) | ||
[![License](https://img.shields.io/cocoapods/l/ForceTouchable.svg?style=flat)](http://cocoapods.org/pods/ForceTouchable) | ||
[![Platform](https://img.shields.io/cocoapods/p/ForceTouchable.svg?style=flat)](http://cocoapods.org/pods/ForceTouchable) | ||
|
@@ -20,6 +19,31 @@ it, simply add the following line to your Podfile: | |
pod "ForceTouchable" | ||
``` | ||
|
||
## Usage | ||
|
||
To use ForceTouchable on your UIViewControllers all you have to do is implement the ForceTouchable protocol. | ||
Most methods are already implemented in case your ForceTouchable implementation is a UIViewController, all you need to implement is `forceTouchPreviewForLocation(CGPoint)`. | ||
|
||
```swift | ||
// MARK: ForceTouchable | ||
extension ViewController: ForceTouchable { | ||
|
||
func forceTouchPreviewForLocation(location: CGPoint) -> ForceTouchPreview? { | ||
guard let indexPath = tableView.indexPathForRowAtPoint(location), | ||
cell = tableView.cellForRowAtIndexPath(indexPath) else { return nil } | ||
|
||
// Create a detail view controller and set its properties. | ||
guard let detailViewController = storyboard?.instantiateViewControllerWithIdentifier("DetailViewController") as? DetailViewController else { return nil } | ||
|
||
let previewDetail = sampleData[indexPath.row] | ||
detailViewController.detailItemTitle = previewDetail.title | ||
|
||
return ForceTouchPreview(previewViewController: detailViewController, touchedView: cell) | ||
} | ||
|
||
} | ||
``` | ||
|
||
## Author | ||
|
||
Ivan Bruel, [email protected] | ||
|