Skip to content

Commit

Permalink
fix a big bug: UIWindow did not disappear blocking Status Bar and cur…
Browse files Browse the repository at this point in the history
…rent view
  • Loading branch information
johnlui committed Jul 23, 2015
1 parent c0995f9 commit b1d88d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
17 changes: 10 additions & 7 deletions SwiftNotice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ class SwiftNotice: NSObject {
static let rv = UIApplication.sharedApplication().keyWindow?.subviews.first as UIView!

static func clear() {
for i in windows {
i.hidden = true
}
self.cancelPreviousPerformRequestsWithTarget(self)
windows.removeAll(keepCapacity: false)
}

static func noticeOnSatusBar(text: String, autoClear: Bool) {
Expand All @@ -89,7 +88,7 @@ class SwiftNotice: NSObject {

if autoClear {
let selector = Selector("hideNotice:")
self.performSelector(selector, withObject: view, afterDelay: 1)
self.performSelector(selector, withObject: window, afterDelay: 1)
}
}
static func wait() {
Expand Down Expand Up @@ -182,13 +181,17 @@ class SwiftNotice: NSObject {

if autoClear {
let selector = Selector("hideNotice:")
self.performSelector(selector, withObject: mainView, afterDelay: 3)
self.performSelector(selector, withObject: window, afterDelay: 3)
}
}

static func hideNotice(sender: AnyObject) {
if sender is UIView {
sender.removeFromSuperview()
if let window = sender as? UIWindow {
if let index = windows.indexOf({ (item) -> Bool in
return item == window
}) {
windows.removeAtIndex(index)
}
}
}
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>

0 comments on commit b1d88d7

Please sign in to comment.