From 8bd4e72c331ff082a3add70a6e2dab206fcd6c08 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 12 Feb 2023 02:46:50 +0800 Subject: [PATCH] Fix macOS Demo applicationDidFinishLaunching not called --- .../SDWebImage Demo.xcodeproj/project.pbxproj | 8 +++++++- Examples/SDWebImage OSX Demo/AppDelegate.h | 1 + Examples/SDWebImage OSX Demo/AppDelegate.m | 6 ++++++ .../Base.lproj/Main.storyboard | 6 +++--- Examples/SDWebImage OSX Demo/WindowController.h | 17 +++++++++++++++++ Examples/SDWebImage OSX Demo/WindowController.m | 13 +++++++++++++ 6 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 Examples/SDWebImage OSX Demo/WindowController.h create mode 100644 Examples/SDWebImage OSX Demo/WindowController.m diff --git a/Examples/SDWebImage Demo.xcodeproj/project.pbxproj b/Examples/SDWebImage Demo.xcodeproj/project.pbxproj index ddf8a658..8b6ceb18 100644 --- a/Examples/SDWebImage Demo.xcodeproj/project.pbxproj +++ b/Examples/SDWebImage Demo.xcodeproj/project.pbxproj @@ -3,12 +3,13 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ 32892E311FAE898C00BE8320 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32892E301FAE898C00BE8320 /* Assets.xcassets */; }; 32892E351FAE89FE00BE8320 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32892E341FAE89FD00BE8320 /* LaunchScreen.storyboard */; }; + 328CA3AB29980A840063950F /* WindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 328CA3AA29980A840063950F /* WindowController.m */; }; 3E75A9861742DBE700DA412D /* CustomPathImages in Resources */ = {isa = PBXBuildFile; fileRef = 3E75A9851742DBE700DA412D /* CustomPathImages */; }; 4314D1AA1D0E1181004B36C9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4314D1A91D0E1181004B36C9 /* main.m */; }; 4314D1AD1D0E1181004B36C9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4314D1AC1D0E1181004B36C9 /* AppDelegate.m */; }; @@ -136,6 +137,8 @@ 327E1C604113A7CEC9AC02DB /* Pods-SDWebImage Watch Demo Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImage Watch Demo Extension.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-SDWebImage Watch Demo Extension/Pods-SDWebImage Watch Demo Extension.debug.xcconfig"; sourceTree = ""; }; 32892E301FAE898C00BE8320 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 32892E341FAE89FD00BE8320 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; + 328CA3A929980A840063950F /* WindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowController.h; sourceTree = ""; }; + 328CA3AA29980A840063950F /* WindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WindowController.m; sourceTree = ""; }; 3E75A9851742DBE700DA412D /* CustomPathImages */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CustomPathImages; sourceTree = SOURCE_ROOT; }; 4314D1A61D0E1181004B36C9 /* SDWebImage TV Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SDWebImage TV Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 4314D1A91D0E1181004B36C9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -275,6 +278,8 @@ children = ( 43A629D11D0DFD000089D7DD /* AppDelegate.h */, 43A629D21D0DFD000089D7DD /* AppDelegate.m */, + 328CA3A929980A840063950F /* WindowController.h */, + 328CA3AA29980A840063950F /* WindowController.m */, 43A629D71D0DFD000089D7DD /* ViewController.h */, 43A629D81D0DFD000089D7DD /* ViewController.m */, 43A629DA1D0DFD000089D7DD /* Assets.xcassets */, @@ -804,6 +809,7 @@ buildActionMask = 2147483647; files = ( 43A629D91D0DFD000089D7DD /* ViewController.m in Sources */, + 328CA3AB29980A840063950F /* WindowController.m in Sources */, 43A629D61D0DFD000089D7DD /* main.m in Sources */, 43A629D31D0DFD000089D7DD /* AppDelegate.m in Sources */, ); diff --git a/Examples/SDWebImage OSX Demo/AppDelegate.h b/Examples/SDWebImage OSX Demo/AppDelegate.h index a9a60529..99adbba0 100644 --- a/Examples/SDWebImage OSX Demo/AppDelegate.h +++ b/Examples/SDWebImage OSX Demo/AppDelegate.h @@ -10,6 +10,7 @@ @interface AppDelegate : NSObject +@property (strong, nonatomic) NSWindowController *windowController; @end diff --git a/Examples/SDWebImage OSX Demo/AppDelegate.m b/Examples/SDWebImage OSX Demo/AppDelegate.m index f1c7e02b..9a7294fa 100644 --- a/Examples/SDWebImage OSX Demo/AppDelegate.m +++ b/Examples/SDWebImage OSX Demo/AppDelegate.m @@ -30,6 +30,12 @@ // For HEIC animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now. [[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]]; } + + NSStoryboard *mainStoryboard = [NSStoryboard storyboardWithName:@"Main" bundle:nil]; + NSWindowController *initialController = [mainStoryboard instantiateControllerWithIdentifier:@"MainWindowController"]; + self.windowController = initialController; + [initialController showWindow:self]; + [initialController.window makeKeyAndOrderFront:self]; } - (void)applicationWillTerminate:(NSNotification *)aNotification { diff --git a/Examples/SDWebImage OSX Demo/Base.lproj/Main.storyboard b/Examples/SDWebImage OSX Demo/Base.lproj/Main.storyboard index 8986ad91..0384fdaa 100644 --- a/Examples/SDWebImage OSX Demo/Base.lproj/Main.storyboard +++ b/Examples/SDWebImage OSX Demo/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -651,7 +651,7 @@ - + diff --git a/Examples/SDWebImage OSX Demo/WindowController.h b/Examples/SDWebImage OSX Demo/WindowController.h new file mode 100644 index 00000000..86e69bb9 --- /dev/null +++ b/Examples/SDWebImage OSX Demo/WindowController.h @@ -0,0 +1,17 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface WindowController : NSWindowController + +@end + +NS_ASSUME_NONNULL_END diff --git a/Examples/SDWebImage OSX Demo/WindowController.m b/Examples/SDWebImage OSX Demo/WindowController.m new file mode 100644 index 00000000..51c9b852 --- /dev/null +++ b/Examples/SDWebImage OSX Demo/WindowController.m @@ -0,0 +1,13 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "WindowController.h" + +@implementation WindowController + +@end