Skip to content

Commit 0dcee61

Browse files
committed
Fixed present window getter.
1 parent e6c8a66 commit 0dcee61

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

SPAlert.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPAlert'
4-
s.version = '3.0.8'
4+
s.version = '3.0.9'
55
s.summary = 'Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.'
66
s.homepage = 'https://github.com/ivanvorobei/SPAlert'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPAlert.git', :tag => s.version }

Sources/SPAlert/SPAlertView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ open class SPAlertView: UIView {
5858
return view
5959
}()
6060

61-
weak open var presentWindow: UIWindow? = UIApplication.shared.windows.first
61+
weak open var presentWindow: UIWindow?
6262

6363
// MARK: - Init
6464

@@ -157,7 +157,13 @@ open class SPAlertView: UIView {
157157
}
158158

159159
open func present(duration: TimeInterval = 1.5, haptic: SPAlertHaptic = .success, completion: (() -> Void)? = nil) {
160+
161+
if self.presentWindow == nil {
162+
self.presentWindow = UIApplication.shared.windows.first
163+
}
164+
160165
guard let window = self.presentWindow else { return }
166+
161167
window.addSubview(self)
162168

163169
// Prepare for present

0 commit comments

Comments
 (0)