From 323bc651d354f3c1329afbc3041d8a24acf2ee9e Mon Sep 17 00:00:00 2001 From: suzuki_keishi Date: Tue, 2 Feb 2016 14:14:45 +0900 Subject: [PATCH] [update]delegate add for actionbutton. --- .travis.yml | 41 +++++++++++++++++++ SKPhotoBrowser.podspec | 2 +- SKPhotoBrowser/SKPhotoBrowser.swift | 12 ++++-- .../AppIcon.appiconset/Contents.json | 5 +++ .../ViewController.swift | 7 +++- 5 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1a165c5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,41 @@ +language: objective-c +osx_image: xcode7.2 +branches: + only: + - master +env: + global: + - LC_CTYPE=en_US.UTF-8 + - LANG=en_US.UTF-8 + - FRAMEWORK_NAME="CountdownLabel" + matrix: + - DESTINATION="OS=9.2,name=iPhone 6" SCHEME="CountdownLabelTests" SDK="iphonesimulator9.2" $ACTION="test" + +before_install: + - brew update + - brew install carthage || brew outdated carthage || brew upgrade carthage + - carthage version + +install: + - gem install xcpretty + - carthage bootstrap --no-use-binaries --platform iOS + +script: + - set -o pipefail + - xcodebuild -version + - xcodebuild -showsdks + - xcodebuild + -project "$FRAMEWORK_NAME.xcodeproj" + -scheme "$SCHEME" + -sdk "$SDK" + -destination "$DESTINATION" + -configuration Debug + ONLY_ACTIVE_ARCH=NO + GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES + GCC_GENERATE_TEST_COVERAGE_FILES=YES + "$ACTION" + | xcpretty -c + +after_success: + - bash <(curl -s https://codecov.io/bash) + diff --git a/SKPhotoBrowser.podspec b/SKPhotoBrowser.podspec index 52ae7c7..31fd956 100644 --- a/SKPhotoBrowser.podspec +++ b/SKPhotoBrowser.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SKPhotoBrowser" - s.version = "1.4.0" + s.version = "1.4.1" s.summary = "Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0." s.homepage = "https://github.com/suzuki-0000/SKPhotoBrowser" s.license = { :type => "MIT", :file => "LICENSE" } diff --git a/SKPhotoBrowser/SKPhotoBrowser.swift b/SKPhotoBrowser/SKPhotoBrowser.swift index 8deeb1f..7bb42e6 100644 --- a/SKPhotoBrowser/SKPhotoBrowser.swift +++ b/SKPhotoBrowser/SKPhotoBrowser.swift @@ -11,6 +11,7 @@ import UIKit @objc public protocol SKPhotoBrowserDelegate { func didShowPhotoAtIndex(index: Int) optional func willDismissAtPageIndex(index: Int) + optional func willShowActionSheet(photoIndex: Int) optional func didDismissAtPageIndex(index: Int) optional func didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: Int) } @@ -207,19 +208,20 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate, UIActionShe doneButton.setImage(doneImage, forState: UIControlState.Normal) doneButton.frame = doneButtonHideFrame doneButton.imageEdgeInsets = UIEdgeInsetsMake(15.25, 15.25, 15.25, 15.25) - doneButton.backgroundColor = UIColor.clearColor() + doneButton.backgroundColor = .clearColor() doneButton.addTarget(self, action: "doneButtonPressed:", forControlEvents: UIControlEvents.TouchUpInside) doneButton.alpha = 0.0 view.addSubview(doneButton) + // action button + toolActionButton = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: "actionButtonPressed") + toolActionButton.tintColor = .whiteColor() + // gesture panGesture = UIPanGestureRecognizer(target: self, action: "panGestureRecognized:") panGesture.minimumNumberOfTouches = 1 panGesture.maximumNumberOfTouches = 1 - // actions - toolActionButton = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: "actionButtonPressed") - toolActionButton.tintColor = UIColor.whiteColor() // transition (this must be last call of view did load.) performPresentAnimation() @@ -822,6 +824,8 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate, UIActionShe public func actionButtonPressed() { let photo = photoAtIndex(currentPageIndex) + delegate?.willShowActionSheet?(currentPageIndex) + if numberOfPhotos > 0 && photo.underlyingImage != nil { if let titles = actionButtonTitles { actionSheet = UIActionSheet() diff --git a/SKPhotoBrowserExample/SKPhotoBrowserExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/SKPhotoBrowserExample/SKPhotoBrowserExample/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80..eeea76c 100644 --- a/SKPhotoBrowserExample/SKPhotoBrowserExample/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/SKPhotoBrowserExample/SKPhotoBrowserExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -59,6 +59,11 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" } ], "info" : { diff --git a/SKPhotoBrowserExample/SKPhotoBrowserExample/ViewController.swift b/SKPhotoBrowserExample/SKPhotoBrowserExample/ViewController.swift index ccf1af9..8b31689 100644 --- a/SKPhotoBrowserExample/SKPhotoBrowserExample/ViewController.swift +++ b/SKPhotoBrowserExample/SKPhotoBrowserExample/ViewController.swift @@ -78,7 +78,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection browser.delegate = self // Can hide the action button by setting to false - // browser.displayAction = false + browser.displayAction = true // Optional action button titles (if left off, it uses activity controller // browser.actionButtonTitles = ["Do One Action", "Do Another Action"] @@ -94,6 +94,10 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection func willDismissAtPageIndex(index: Int) { // do some handle if you need } + + func willShowActionSheet(photoIndex: Int) { + // do some handle if you need + } func didDismissAtPageIndex(index: Int) { // do some handle if you need @@ -102,6 +106,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection func didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: Int) { // handle dismissing custom actions } + }