From 2b818f5c4f21ca8fdcb0f8e5095d953e1a4bd4a2 Mon Sep 17 00:00:00 2001 From: Changnam Hong Date: Tue, 9 Jan 2018 17:44:47 +0900 Subject: [PATCH] Update UIScrollViewDelegate --- .../TileImageView/TileImageScrollView.swift | 13 +++++++++++++ .../TileImageView/TileImageViewDataSource.swift | 8 ++++++++ StorytellingKit.podspec | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/MyTileImageViewer/TileImageView/TileImageScrollView.swift b/MyTileImageViewer/TileImageView/TileImageScrollView.swift index 75ea409..dd054cb 100644 --- a/MyTileImageViewer/TileImageView/TileImageScrollView.swift +++ b/MyTileImageViewer/TileImageView/TileImageScrollView.swift @@ -15,6 +15,8 @@ import UIKit open class TileImageScrollView: UIScrollView { + var tileImageScrollViewDelegate: TileImageScrollViewDelegate? + private var contentView: TileImageContentView? weak var dataSource: TileImageViewDataSource? private var currentBounds = CGSize.zero @@ -41,6 +43,8 @@ open class TileImageScrollView: UIScrollView { self.dataSource = dataSource + self.tileImageScrollViewDelegate = dataSource.delegate + let tileImageView = TileImageView(dataSource: dataSource) tileImageView.dataSource = dataSource @@ -99,6 +103,15 @@ extension TileImageScrollView: UIScrollViewDelegate { let topY = max((bounds.height - contentSize.height)/2, 0) contentView?.frame.origin = CGPoint(x: topX, y: topY) } + + public func scrollViewDidScroll(_ scrollView: UIScrollView) { + tileImageScrollViewDelegate?.didScroll(scrollView: self) + } + + public func scrollViewDidZoom(_ scrollView: UIScrollView) { + tileImageScrollViewDelegate?.didZoom(scrollView: self) + } + } // MARK: DoubleTappable diff --git a/MyTileImageViewer/TileImageView/TileImageViewDataSource.swift b/MyTileImageViewer/TileImageView/TileImageViewDataSource.swift index ca9eda9..08c3f7d 100644 --- a/MyTileImageViewer/TileImageView/TileImageViewDataSource.swift +++ b/MyTileImageViewer/TileImageView/TileImageViewDataSource.swift @@ -8,8 +8,15 @@ import UIKit +public protocol TileImageScrollViewDelegate { + func didScroll(scrollView: TileImageScrollView) + func didZoom(scrollView: TileImageScrollView) +} + public protocol TileImageViewDataSource: class { + var delegate: TileImageScrollViewDelegate? { get set } + // full Image size var originalImageSize: CGSize { get set } @@ -43,3 +50,4 @@ extension TileImageViewDataSource { return self.originalImageSize } } + diff --git a/StorytellingKit.podspec b/StorytellingKit.podspec index 1e63c8d..5050e6f 100644 --- a/StorytellingKit.podspec +++ b/StorytellingKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'StorytellingKit' - s.version = '0.1.1' + s.version = '0.1.2' s.summary = 'High Quality Image ScrollView with storytelling contents.' s.description = <<-DESC