[update]delegate add for actionbutton.
This commit is contained in:
parent
19a426e4c8
commit
323bc651d3
|
|
@ -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)
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "SKPhotoBrowser"
|
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.summary = "Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0."
|
||||||
s.homepage = "https://github.com/suzuki-0000/SKPhotoBrowser"
|
s.homepage = "https://github.com/suzuki-0000/SKPhotoBrowser"
|
||||||
s.license = { :type => "MIT", :file => "LICENSE" }
|
s.license = { :type => "MIT", :file => "LICENSE" }
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import UIKit
|
||||||
@objc public protocol SKPhotoBrowserDelegate {
|
@objc public protocol SKPhotoBrowserDelegate {
|
||||||
func didShowPhotoAtIndex(index: Int)
|
func didShowPhotoAtIndex(index: Int)
|
||||||
optional func willDismissAtPageIndex(index: Int)
|
optional func willDismissAtPageIndex(index: Int)
|
||||||
|
optional func willShowActionSheet(photoIndex: Int)
|
||||||
optional func didDismissAtPageIndex(index: Int)
|
optional func didDismissAtPageIndex(index: Int)
|
||||||
optional func didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: 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.setImage(doneImage, forState: UIControlState.Normal)
|
||||||
doneButton.frame = doneButtonHideFrame
|
doneButton.frame = doneButtonHideFrame
|
||||||
doneButton.imageEdgeInsets = UIEdgeInsetsMake(15.25, 15.25, 15.25, 15.25)
|
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.addTarget(self, action: "doneButtonPressed:", forControlEvents: UIControlEvents.TouchUpInside)
|
||||||
doneButton.alpha = 0.0
|
doneButton.alpha = 0.0
|
||||||
view.addSubview(doneButton)
|
view.addSubview(doneButton)
|
||||||
|
|
||||||
|
// action button
|
||||||
|
toolActionButton = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: "actionButtonPressed")
|
||||||
|
toolActionButton.tintColor = .whiteColor()
|
||||||
|
|
||||||
// gesture
|
// gesture
|
||||||
panGesture = UIPanGestureRecognizer(target: self, action: "panGestureRecognized:")
|
panGesture = UIPanGestureRecognizer(target: self, action: "panGestureRecognized:")
|
||||||
panGesture.minimumNumberOfTouches = 1
|
panGesture.minimumNumberOfTouches = 1
|
||||||
panGesture.maximumNumberOfTouches = 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.)
|
// transition (this must be last call of view did load.)
|
||||||
performPresentAnimation()
|
performPresentAnimation()
|
||||||
|
|
@ -822,6 +824,8 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate, UIActionShe
|
||||||
public func actionButtonPressed() {
|
public func actionButtonPressed() {
|
||||||
let photo = photoAtIndex(currentPageIndex)
|
let photo = photoAtIndex(currentPageIndex)
|
||||||
|
|
||||||
|
delegate?.willShowActionSheet?(currentPageIndex)
|
||||||
|
|
||||||
if numberOfPhotos > 0 && photo.underlyingImage != nil {
|
if numberOfPhotos > 0 && photo.underlyingImage != nil {
|
||||||
if let titles = actionButtonTitles {
|
if let titles = actionButtonTitles {
|
||||||
actionSheet = UIActionSheet()
|
actionSheet = UIActionSheet()
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,11 @@
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"size" : "76x76",
|
"size" : "76x76",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"size" : "83.5x83.5",
|
||||||
|
"scale" : "2x"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info" : {
|
"info" : {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
|
||||||
browser.delegate = self
|
browser.delegate = self
|
||||||
|
|
||||||
// Can hide the action button by setting to false
|
// 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
|
// Optional action button titles (if left off, it uses activity controller
|
||||||
// browser.actionButtonTitles = ["Do One Action", "Do Another Action"]
|
// browser.actionButtonTitles = ["Do One Action", "Do Another Action"]
|
||||||
|
|
@ -94,6 +94,10 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
|
||||||
func willDismissAtPageIndex(index: Int) {
|
func willDismissAtPageIndex(index: Int) {
|
||||||
// do some handle if you need
|
// do some handle if you need
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func willShowActionSheet(photoIndex: Int) {
|
||||||
|
// do some handle if you need
|
||||||
|
}
|
||||||
|
|
||||||
func didDismissAtPageIndex(index: Int) {
|
func didDismissAtPageIndex(index: Int) {
|
||||||
// do some handle if you need
|
// do some handle if you need
|
||||||
|
|
@ -102,6 +106,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
|
||||||
func didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: Int) {
|
func didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: Int) {
|
||||||
// handle dismissing custom actions
|
// handle dismissing custom actions
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue