From 04f1cc82de1e212a614b3d176c36478e6ac9bb4d Mon Sep 17 00:00:00 2001 From: Suric zhang <372081349@qq.com> Date: Thu, 11 Aug 2016 17:07:34 +0800 Subject: [PATCH] add cancel delegate --- .../xcdebugger/Breakpoints_v2.xcbkptlist | 18 +++++++++--------- DropdownMenu/DropUpMenu.swift | 6 ++++++ DropdownMenu/DropdownMenu.swift | 5 +++++ .../DropdownMenuDemo/ViewController.swift | 4 ++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/DropdownMenu.xcworkspace/xcuserdata/zhangxiaolian.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/DropdownMenu.xcworkspace/xcuserdata/zhangxiaolian.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index a4eab33..22629d8 100644 --- a/DropdownMenu.xcworkspace/xcuserdata/zhangxiaolian.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/DropdownMenu.xcworkspace/xcuserdata/zhangxiaolian.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -20,11 +20,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "DropdownMenu/DropUpMenu.swift" - timestampString = "492575779.702114" + timestampString = "492599077.671665" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "29" - endingLineNumber = "29" + startingLineNumber = "30" + endingLineNumber = "30" landmarkName = "dropUpMenu(_:didSelectRowAtIndexPath:)" landmarkType = "5"> @@ -36,11 +36,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "DropdownMenu/DropUpMenu.swift" - timestampString = "492577289.049253" + timestampString = "492599207.097013" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "241" - endingLineNumber = "241" + startingLineNumber = "247" + endingLineNumber = "247" landmarkName = "tableView(_:didSelectRowAtIndexPath:)" landmarkType = "5"> @@ -52,11 +52,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "DropdownMenu/DropUpMenu.swift" - timestampString = "492576784.251824" + timestampString = "492599077.671665" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "168" - endingLineNumber = "168" + startingLineNumber = "172" + endingLineNumber = "172" landmarkName = "hideMenu()" landmarkType = "5"> diff --git a/DropdownMenu/DropUpMenu.swift b/DropdownMenu/DropUpMenu.swift index 20dca5d..8a91a17 100644 --- a/DropdownMenu/DropUpMenu.swift +++ b/DropdownMenu/DropUpMenu.swift @@ -19,6 +19,7 @@ import UIKit public protocol DropUpMenuDelegate: class { func dropUpMenu(dropUpMenu: DropUpMenu, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell? func dropUpMenu(dropUpMenu: DropUpMenu, didSelectRowAtIndexPath indexPath: NSIndexPath) + func dropUpMenuCancel(dropUpMenu: DropUpMenu) } public extension DropUpMenuDelegate { @@ -28,6 +29,9 @@ public extension DropUpMenuDelegate { func dropUpMenu(dropUpMenu: DropUpMenu, didSelectRowAtIndexPath indexPath: NSIndexPath) { } + + func dropUpMenuCancel(dropUpMenu: DropUpMenu) { + } } private let screenRect = UIScreen.mainScreen().bounds @@ -169,6 +173,8 @@ public class DropUpMenu: UIView { self.backgroundColor = self.backgroudBeginColor self.tableView.frame.origin.y = screenRect.height - self.bottomOffsetY }) { (finished) in + self.delegate?.dropUpMenuCancel(self) + self.barCoverView.removeFromSuperview() self.removeFromSuperview() self.isShow = false diff --git a/DropdownMenu/DropdownMenu.swift b/DropdownMenu/DropdownMenu.swift index 37e50cf..771053b 100644 --- a/DropdownMenu/DropdownMenu.swift +++ b/DropdownMenu/DropdownMenu.swift @@ -11,6 +11,7 @@ import UIKit public protocol DropdownMenuDelegate: class { func dropdownMenu(dropdownMenu: DropdownMenu, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell? func dropdownMenu(dropdownMenu: DropdownMenu, didSelectRowAtIndexPath indexPath: NSIndexPath) + func dropdownMenuCancel(dropdownMenu: DropdownMenu) } public extension DropdownMenuDelegate { @@ -20,6 +21,9 @@ public extension DropdownMenuDelegate { func dropdownMenu(dropdownMenu: DropdownMenu, didSelectRowAtIndexPath indexPath: NSIndexPath) { } + + func dropdownMenuCancel(dropdownMenu: DropdownMenu) { + } } public class DropdownMenu: UIView { @@ -161,6 +165,7 @@ public class DropdownMenu: UIView { self.backgroundColor = self.backgroudBeginColor self.tableView.frame.origin.y = -self.tableViewHeight }) { (finished) in + self.delegate?.dropdownMenuCancel(self) self.barCoverView.removeFromSuperview() self.removeFromSuperview() self.isShow = false diff --git a/DropdownMenuDemo/DropdownMenuDemo/ViewController.swift b/DropdownMenuDemo/DropdownMenuDemo/ViewController.swift index 7470e64..62bdc1b 100644 --- a/DropdownMenuDemo/DropdownMenuDemo/ViewController.swift +++ b/DropdownMenuDemo/DropdownMenuDemo/ViewController.swift @@ -73,4 +73,8 @@ extension ViewController: DropUpMenuDelegate { print("Display success") } } + + func dropUpMenuCancel(dropUpMenu: DropUpMenu) { + print("select cancel") + } }