From e6431b813463e12cd3bcd1de62d6902b48515290 Mon Sep 17 00:00:00 2001 From: Ahmed Mohamed Abdelmagied Date: Thu, 5 Dec 2019 13:08:01 +0200 Subject: [PATCH] Add support for iOS 13 (#1) * Add support for iOS 13 changes on UIWindow management * update travis * Update podspec to version 2.3.1 --- .travis.yml | 2 +- ActionSheetPicker-3.0.podspec | 2 +- Pickers/SWActionSheet.m | 26 +++++++++++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4975ae0a5..c860fed02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode9 +osx_image: xcode11.2 script: - xcodebuild clean build test -workspace ActionSheetPicker-3.0.xcworkspace -scheme ActionSheetPicker -sdk iphonesimulator -destination "platform=iOS Simulator,OS=11.0,name=iPhone X" ONLY_ACTIVE_ARCH=NO diff --git a/ActionSheetPicker-3.0.podspec b/ActionSheetPicker-3.0.podspec index 523d72571..6c4ad3dbc 100644 --- a/ActionSheetPicker-3.0.podspec +++ b/ActionSheetPicker-3.0.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do | s | s.name = 'ActionSheetPicker-3.0' - s.version = '2.3.0' + s.version = '2.3.1' s.summary = 'Better version of ActionSheetPicker with support iOS7 and other improvements.' s.homepage = 'http://skywinder.github.io/ActionSheetPicker-3.0' s.license = 'BSD' diff --git a/Pickers/SWActionSheet.m b/Pickers/SWActionSheet.m index da8ddb45d..857511ee3 100644 --- a/Pickers/SWActionSheet.m +++ b/Pickers/SWActionSheet.m @@ -87,13 +87,25 @@ - (UIWindow *)window } else { - return SWActionSheetWindow = ({ - UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - window.windowLevel = self.windowLevel; - window.backgroundColor = [UIColor clearColor]; - window.rootViewController = [SWActionSheetVC new]; - window; - }); + UIWindow *window = nil; + if (@available(iOS 13.0, *)) { + UIScene *scene = [UIApplication sharedApplication].connectedScenes.allObjects.firstObject; + if (scene && [scene isKindOfClass:[UIWindowScene class]]) { + UIWindowScene *windowScene = (UIWindowScene *)scene; + window = [[UIWindow alloc] initWithWindowScene:windowScene]; + } + } + + if (window == nil) { + window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + } + + window.windowLevel = self.windowLevel; + window.backgroundColor = [UIColor clearColor]; + window.rootViewController = [SWActionSheetVC new]; + + SWActionSheetWindow = window; + return SWActionSheetWindow; } }