[update]delegate add for actionbutton.

This commit is contained in:
suzuki_keishi 2016-02-02 14:14:45 +09:00
parent 19a426e4c8
commit 323bc651d3
5 changed files with 61 additions and 6 deletions

41
.travis.yml Normal file
View File

@ -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)

View File

@ -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" }

View File

@ -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()

View File

@ -59,6 +59,11 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {

View File

@ -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"]
@ -95,6 +95,10 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
// 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
}
}