Skip to content

Commit 1e52b7e

Browse files
committed
barButton.addTarget(self, action: (position == .NavigationBarButtonAsLeft) ? #selector(UIViewController.leftBarButtonAction(_:)) : #selector(UIViewController.rightBarButtonAction(_:)), forControlEvents: .TouchUpInside)
1 parent 6f4bf40 commit 1e52b7e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

SwiftMan/Extension/UIKit/UIViewController/UIViewController+UIViewController+NavigationBar.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ extension UIViewController{
3939
let barButton = UIButton(type: .Custom)
4040
barButton.frame = CGRectMake(0, 0, 45, 40)
4141
barButton.backgroundColor = UIColor.clearColor()
42-
barButton.addTarget(self, action: Selector(position.rawValue), forControlEvents: .TouchUpInside)
42+
// return self.scheduledTimerWithTimeInterval(timeInterval, target: self, selector: #selector(NSTimer.executeBlockWithTimer(_:)), userInfo: unsafeBitCast(block, AnyObject.self), repeats: repeats)
43+
44+
// barButton.addTarget(self, action: Selector(position.rawValue), forControlEvents: .TouchUpInside)
45+
barButton.addTarget(self, action: (position == .NavigationBarButtonAsLeft) ? #selector(UIViewController.leftBarButtonAction(_:)) : #selector(UIViewController.rightBarButtonAction(_:)), forControlEvents: .TouchUpInside)
4346
barButton.imageView?.contentMode = .ScaleAspectFit
4447
if let image = normalImage{
4548
barButton.setImage(image, forState: .Normal)
@@ -109,7 +112,7 @@ extension UIViewController{
109112

110113
}
111114

112-
@objc func leftBarButtonAction(sender: UIButton?)
115+
@objc private func leftBarButtonAction(sender: UIButton?)
113116
{
114117
let switchEffect = objc_getAssociatedObject(self, &AssociatedKeys.SwitchEffectKey) as? Bool
115118
if let _ = switchEffect {
@@ -126,7 +129,7 @@ extension UIViewController{
126129
block(barButton: sender)
127130
}
128131

129-
@objc func rightBarButtonAction(sender: UIButton?)
132+
@objc private func rightBarButtonAction(sender: UIButton?)
130133
{
131134
let switchEffect = objc_getAssociatedObject(self, &AssociatedKeys.SwitchEffectKey) as? Bool
132135
if let _ = switchEffect {

0 commit comments

Comments
 (0)