Skip to content

Commit

Permalink
add cancel delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
Suric zhang committed Aug 11, 2016
1 parent 144a383 commit 04f1cc8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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">
</BreakpointContent>
Expand All @@ -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">
</BreakpointContent>
Expand All @@ -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">
<Locations>
Expand Down
6 changes: 6 additions & 0 deletions DropdownMenu/DropUpMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,6 +29,9 @@ public extension DropUpMenuDelegate {

func dropUpMenu(dropUpMenu: DropUpMenu, didSelectRowAtIndexPath indexPath: NSIndexPath) {
}

func dropUpMenuCancel(dropUpMenu: DropUpMenu) {
}
}

private let screenRect = UIScreen.mainScreen().bounds
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions DropdownMenu/DropdownMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -20,6 +21,9 @@ public extension DropdownMenuDelegate {

func dropdownMenu(dropdownMenu: DropdownMenu, didSelectRowAtIndexPath indexPath: NSIndexPath) {
}

func dropdownMenuCancel(dropdownMenu: DropdownMenu) {
}
}

public class DropdownMenu: UIView {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions DropdownMenuDemo/DropdownMenuDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@ extension ViewController: DropUpMenuDelegate {
print("Display success")
}
}

func dropUpMenuCancel(dropUpMenu: DropUpMenu) {
print("select cancel")
}
}

0 comments on commit 04f1cc8

Please sign in to comment.