From 4e9256254783552d5a82f74d2a1be639681c2b64 Mon Sep 17 00:00:00 2001 From: Peter Livesey Date: Sun, 23 Nov 2014 12:30:33 -0800 Subject: [PATCH] Fixing a bug where finding the right window wouldn't work. Now, even if you call rateApp() from a UIActionSheet, it will actually present the modal. --- Source/Armchair.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Armchair.swift b/Source/Armchair.swift index 62c4f69..bf2aafd 100644 --- a/Source/Armchair.swift +++ b/Source/Armchair.swift @@ -1597,13 +1597,16 @@ public class Manager : ArmchairManager { } private func getRootViewController() -> UIViewController? { - if let window = UIApplication.sharedApplication().keyWindow { + if var window = UIApplication.sharedApplication().keyWindow { if window.windowLevel != UIWindowLevelNormal { var windows: NSArray = UIApplication.sharedApplication().windows - for window in windows { - if window.windowLevel == UIWindowLevelNormal { - break + for candidateWindow in windows { + if let candidateWindow = candidateWindow as? UIWindow { + if candidateWindow.windowLevel == UIWindowLevelNormal { + window = candidateWindow + break + } } } }