diff --git a/Examples/SDWebImage Demo/AppDelegate.m b/Examples/SDWebImage Demo/AppDelegate.m index c6a005b4..74342347 100644 --- a/Examples/SDWebImage Demo/AppDelegate.m +++ b/Examples/SDWebImage Demo/AppDelegate.m @@ -10,6 +10,7 @@ #import "MasterViewController.h" #import +#import @implementation AppDelegate @@ -24,6 +25,15 @@ NSString *fileName = [[SDImageCache sharedImageCache] cachePathForKey:key].lastPathComponent; return [bundledPath stringByAppendingPathComponent:fileName.stringByDeletingPathExtension]; }; + + if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) { + // iOS 14 supports WebP built-in + [[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]]; + } else { + // iOS 13 does not supports WebP, use third-party codec + [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; + } + [[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]]; // For HEIC static/animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; // Override point for customization after application launch. diff --git a/Examples/SDWebImage Demo/MasterViewController.m b/Examples/SDWebImage Demo/MasterViewController.m index 20e60b68..e781257a 100644 --- a/Examples/SDWebImage Demo/MasterViewController.m +++ b/Examples/SDWebImage Demo/MasterViewController.m @@ -9,7 +9,6 @@ #import "MasterViewController.h" #import "DetailViewController.h" #import -#import @interface MyCustomTableViewCell : UITableViewCell @@ -52,9 +51,6 @@ target:self action:@selector(flushCache)]; - [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; // For WebP static/animated image - [[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]]; // For HEIC static/animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now. - // HTTP NTLM auth example // Add your NTLM image url to the array below and replace the credentials [SDWebImageDownloader sharedDownloader].config.username = @"httpwatch"; diff --git a/Examples/SDWebImage OSX Demo/AppDelegate.m b/Examples/SDWebImage OSX Demo/AppDelegate.m index 4ddb742b..23aaee7f 100644 --- a/Examples/SDWebImage OSX Demo/AppDelegate.m +++ b/Examples/SDWebImage OSX Demo/AppDelegate.m @@ -8,6 +8,9 @@ #import "AppDelegate.h" +#import +#import + @interface AppDelegate () @end @@ -16,6 +19,14 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application + if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) { + // iOS 14 supports WebP built-in + [[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]]; + } else { + // iOS 13 does not supports WebP, use third-party codec + [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; + } + [[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]]; // For HEIC static/animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now. } - (void)applicationWillTerminate:(NSNotification *)aNotification { diff --git a/Examples/SDWebImage OSX Demo/ViewController.m b/Examples/SDWebImage OSX Demo/ViewController.m index c5e39874..b59f236f 100644 --- a/Examples/SDWebImage OSX Demo/ViewController.m +++ b/Examples/SDWebImage OSX Demo/ViewController.m @@ -8,7 +8,6 @@ #import "ViewController.h" #import -#import @interface ViewController () @@ -25,8 +24,6 @@ - (void)viewDidLoad { [super viewDidLoad]; - [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; - // For animated GIF rendering, set `animates` to YES or will only show the first frame self.imageView2.animates = YES; // `SDAnimatedImageRep` can be used for built-in `NSImageView` to support better GIF & APNG rendering as well. No need `SDAnimatedImageView` self.imageView4.animates = YES; diff --git a/Examples/SDWebImage TV Demo/AppDelegate.m b/Examples/SDWebImage TV Demo/AppDelegate.m index 1d02f83a..bdb7c983 100644 --- a/Examples/SDWebImage TV Demo/AppDelegate.m +++ b/Examples/SDWebImage TV Demo/AppDelegate.m @@ -8,6 +8,9 @@ #import "AppDelegate.h" +#import +#import + @interface AppDelegate () @end @@ -17,6 +20,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. + if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) { + // iOS 14 supports WebP built-in + [[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]]; + } else { + // iOS 13 does not supports WebP, use third-party codec + [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; + } + [[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]]; // For HEIC static/animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now. + return YES; } diff --git a/Examples/SDWebImage TV Demo/ViewController.m b/Examples/SDWebImage TV Demo/ViewController.m index f5414fbb..ff23b533 100644 --- a/Examples/SDWebImage TV Demo/ViewController.m +++ b/Examples/SDWebImage TV Demo/ViewController.m @@ -8,7 +8,6 @@ #import "ViewController.h" #import -#import @interface ViewController () @@ -25,7 +24,6 @@ - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. - [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; [self.imageView1 sd_setImageWithURL:[NSURL URLWithString:@"https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"]]; [self.imageView2 sd_setImageWithURL:[NSURL URLWithString:@"http://www.ioncannon.net/wp-content/uploads/2011/06/test2.webp"]]; diff --git a/Examples/SDWebImage Watch Demo Extension/ExtensionDelegate.m b/Examples/SDWebImage Watch Demo Extension/ExtensionDelegate.m index 1aa5784e..c7e3716f 100644 --- a/Examples/SDWebImage Watch Demo Extension/ExtensionDelegate.m +++ b/Examples/SDWebImage Watch Demo Extension/ExtensionDelegate.m @@ -8,10 +8,21 @@ #import "ExtensionDelegate.h" +#import +#import + @implementation ExtensionDelegate - (void)applicationDidFinishLaunching { // Perform any final initialization of your application. + if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) { + // iOS 14 supports WebP built-in + [[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]]; + } else { + // iOS 13 does not supports WebP, use third-party codec + [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; + } + [[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]]; // For HEIC static/animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now. } - (void)applicationDidBecomeActive { diff --git a/Examples/SDWebImage Watch Demo Extension/InterfaceController.m b/Examples/SDWebImage Watch Demo Extension/InterfaceController.m index 6bfd08d2..2c76c536 100644 --- a/Examples/SDWebImage Watch Demo Extension/InterfaceController.m +++ b/Examples/SDWebImage Watch Demo Extension/InterfaceController.m @@ -8,8 +8,6 @@ #import "InterfaceController.h" #import -#import - @interface InterfaceController() @@ -27,7 +25,6 @@ [super awakeWithContext:context]; // Configure interface objects here. - [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]]; } - (void)willActivate {