Skip to content

Commit b102d45

Browse files
author
Michael Skiba
committed
added a reference to the gallery image view controller to the action handler
added a
1 parent 4cd1d4f commit b102d45

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

RIGImageGallery/RIGImageGalleryViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111
public class RIGImageGalleryViewController: UIPageViewController {
1212

1313
/// An optional closure to execute if the action button is tapped
14-
public var actionButtonHandler: (RIGImageGalleryItem -> ())?
14+
public var actionButtonHandler: ((gallery: RIGImageGalleryViewController, item:RIGImageGalleryItem) -> ())?
1515

1616
/// An optional closure to allow cutom trait collection change handling
1717
public var traitCollectionChangeHandler: (RIGImageGalleryViewController -> ())? {
@@ -225,7 +225,7 @@ extension RIGImageGalleryViewController {
225225

226226
func performAction(sender: UIBarButtonItem) {
227227
if let item = currentImageViewController?.viewerItem {
228-
actionButtonHandler?(item)
228+
actionButtonHandler?(gallery: self, item: item)
229229
}
230230
}
231231

RIGImageGalleryDemo/View Controller/ViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ private extension ViewController {
5151
let photoViewController = loadImages()
5252
photoViewController.dismissHandler = dismissPhotoViewer
5353
photoViewController.actionButtonHandler = actionButtonHandler
54+
photoViewController.actionButton = UIBarButtonItem(barButtonSystemItem: .Action, target: nil, action: nil)
5455
photoViewController.traitCollectionChangeHandler = traitCollectionChangeHandler
5556
photoViewController.countUpdateHandler = updateCount
5657
let navigationController = navBarWrappedViewController(photoViewController)
@@ -65,7 +66,7 @@ private extension ViewController {
6566
dismissViewControllerAnimated(true, completion: nil)
6667
}
6768

68-
func actionButtonHandler(galleryItem: RIGImageGalleryItem) {
69+
func actionButtonHandler(_: RIGImageGalleryViewController,galleryItem: RIGImageGalleryItem) {
6970
}
7071

7172
func updateCount(gallery: RIGImageGalleryViewController, position: Int, total: Int) {

RIGImageGalleryTests/ImageGalleryViewControllerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ImageGalleryViewControllerTests: XCTestCase {
6666
waitForExpectationsWithTimeout(1.0, handler: nil)
6767
imageGallery.doneButton = UIBarButtonItem()
6868
let dismissFired = expectationWithDescription("dismiss handler will fire on completion")
69-
imageGallery.dismissHandler = {
69+
imageGallery.dismissHandler = { _ in
7070
dismissFired.fulfill()
7171
}
7272
imageGallery.performSelector((imageGallery.navigationItem.leftBarButtonItem?.action)!, withObject: imageGallery)

0 commit comments

Comments
 (0)