diff --git a/ProgressHUD.podspec b/ProgressHUD.podspec index 6d06e23..a4d9ffd 100644 --- a/ProgressHUD.podspec +++ b/ProgressHUD.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'ProgressHUD' - s.version = '13.8.3' + s.version = '13.8.4' s.license = 'MIT' s.summary = 'A lightweight and easy-to-use Progress HUD for iOS.' diff --git a/ProgressHUD/Sources/ProgressHUD.swift b/ProgressHUD/Sources/ProgressHUD.swift index aa284b6..0fbbd6a 100644 --- a/ProgressHUD/Sources/ProgressHUD.swift +++ b/ProgressHUD/Sources/ProgressHUD.swift @@ -13,7 +13,7 @@ import UIKit public class ProgressHUD: UIView { - var main = UIApplication.shared.windows.first ?? UIWindow() + var main: UIWindow! // Banner properties var viewBanner: UIToolbar? @@ -91,7 +91,7 @@ extension ProgressHUD { removeDelayTimer() - setupNotifications() + setupWindow() setupBackground(interaction) setupToolbar() setupStatus(text) @@ -124,6 +124,7 @@ extension ProgressHUD { } setupSizes(text, animation) + setupNotifications() setupPosition() displayHUD() } @@ -170,7 +171,17 @@ extension ProgressHUD { } } -// MARK: - Background View +// MARK: - Window +extension ProgressHUD { + + private func setupWindow() { + if (main == nil) { + main = UIApplication.shared.windows.first + } + } +} + +// MARK: - Background extension ProgressHUD { private func removeBackground() { @@ -455,19 +466,17 @@ extension ProgressHUD { } } - private func keyboardHeight() -> CGFloat { - if let keyboardWindowClass = NSClassFromString("UIRemoteKeyboardWindow"), - let inputSetContainerView = NSClassFromString("UIInputSetContainerView"), - let inputSetHostView = NSClassFromString("UIInputSetHostView") { - - for window in UIApplication.shared.windows { - if window.isKind(of: keyboardWindowClass) { - for firstSubView in window.subviews { - if firstSubView.isKind(of: inputSetContainerView) { - for secondSubView in firstSubView.subviews { - if secondSubView.isKind(of: inputSetHostView) { - return secondSubView.frame.size.height - } + func keyboardHeight() -> CGFloat { + let windows = UIApplication.shared.windows + for window in windows { + for view in window.subviews { + if String(describing: type(of: view)).hasPrefix("UIInputSetContainerView") { + for subview in view.subviews { + if String(describing: type(of: subview)).hasPrefix("UIInputSetHostView") { + let screenRect = UIScreen.main.bounds + let keyboardRect = window.convert(subview.frame, to: nil) + if keyboardRect.intersects(screenRect) { + return subview.frame.height } } } diff --git a/ProgressHUD/app.xcodeproj/project.pbxproj b/ProgressHUD/app.xcodeproj/project.pbxproj index 8451aa3..b7eacda 100644 --- a/ProgressHUD/app.xcodeproj/project.pbxproj +++ b/ProgressHUD/app.xcodeproj/project.pbxproj @@ -129,7 +129,6 @@ 29D29EF01D9A59E4006CA074 = { CreatedOnToolsVersion = 8.0; LastSwiftMigration = 1000; - ProvisioningStyle = Manual; SystemCapabilities = { com.apple.BackgroundModes = { enabled = 1; @@ -329,7 +328,8 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = NO; CODE_SIGN_ENTITLEMENTS = ""; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -337,7 +337,7 @@ INFOPLIST_FILE = app/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited)"; - MARKETING_VERSION = 13.8.3; + MARKETING_VERSION = 13.8.4; PRODUCT_BUNDLE_IDENTIFIER = com.relatedcode.progresshud; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -360,14 +360,15 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = NO; CODE_SIGN_ENTITLEMENTS = ""; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = app/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited)"; - MARKETING_VERSION = 13.8.3; + MARKETING_VERSION = 13.8.4; PRODUCT_BUNDLE_IDENTIFIER = com.relatedcode.progresshud; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/ProgressHUD/app/AppDelegate.swift b/ProgressHUD/app/AppDelegate.swift index 5d16019..9f6b456 100644 --- a/ProgressHUD/app/AppDelegate.swift +++ b/ProgressHUD/app/AppDelegate.swift @@ -17,6 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { + window = UIWindow(frame: UIScreen.main.bounds) let viewController = ViewController(nibName: "ViewController", bundle: nil) diff --git a/README.md b/README.md index 9d4ad66..4ab1b8e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ ## WHAT'S NEW +### Version: 13.8.4 + +- Corrected the window initialization issue where the `ProgressHUD` class was initialized before the 'main' window was created. +- Resolved the keyboard height discrepancy that occurred when the keyboard was already visible before displaying the HUD. + ### Version: 13.8.3 - Removed the `AlertIcon` feature. Please use the `symbol:` parameter for similar functionality. diff --git a/VERSION.txt b/VERSION.txt index 5d32a75..5389ed8 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -13.8.3 +13.8.4