@@ -8,8 +8,10 @@ public protocol ImageDataSource:class {
88public class ImageCarouselViewController : UIPageViewController {
99
1010 weak var imageDatasource : ImageDataSource ?
11+ weak var sourceView : UIImageView !
12+
1113 var initialIndex = 0
12- var sourceView : UIImageView !
14+
1315 var theme : ImageViewerTheme = . light {
1416 didSet {
1517 navItem. leftBarButtonItem? . tintColor = theme. tintColor
@@ -19,7 +21,7 @@ public class ImageCarouselViewController:UIPageViewController {
1921
2022 var options : [ ImageViewerOption ] = [ ]
2123
22- weak var rightNavItemDelegate : RightNavItemDelegate ?
24+ private var onRightNavBarTapped : ( ( Int ) -> Void ) ?
2325
2426 private( set) lazy var navBar : UINavigationBar = {
2527 let _navBar = UINavigationBar ( frame: . zero)
@@ -91,20 +93,20 @@ public class ImageCarouselViewController:UIPageViewController {
9193 self . theme = theme
9294 case . closeIcon( let icon) :
9395 navItem. leftBarButtonItem? . image = icon
94- case . rightNavItemTitle( let title, let delegate ) :
96+ case . rightNavItemTitle( let title, let onTap ) :
9597 navItem. rightBarButtonItem = UIBarButtonItem (
9698 title: title,
9799 style: . plain,
98100 target: self ,
99101 action: #selector( diTapRightNavBarItem ( _: ) ) )
100- rightNavItemDelegate = delegate
101- case . rightNavItemIcon( let icon, let delegate ) :
102+ onRightNavBarTapped = onTap
103+ case . rightNavItemIcon( let icon, let onTap ) :
102104 navItem. rightBarButtonItem = UIBarButtonItem (
103105 image: icon,
104106 style: . plain,
105107 target: self ,
106108 action: #selector( diTapRightNavBarItem ( _: ) ) )
107- rightNavItemDelegate = delegate
109+ onRightNavBarTapped = onTap
108110 }
109111 }
110112 }
@@ -155,10 +157,10 @@ public class ImageCarouselViewController:UIPageViewController {
155157
156158 @objc
157159 func diTapRightNavBarItem( _ sender: UIBarButtonItem ) {
158- guard let _delegate = rightNavItemDelegate ,
160+ guard let onTap = onRightNavBarTapped ,
159161 let _firstVC = viewControllers? . first as? ImageViewerController
160162 else { return }
161- _delegate . imageViewer ( self , didTapRightNavItem : _firstVC. index)
163+ onTap ( _firstVC. index)
162164 }
163165
164166 override public var preferredStatusBarStyle : UIStatusBarStyle {
0 commit comments