Update the Example of WebP coder for iOS/macOS/tvOS/watchOS
This commit is contained in:
parent
62a6ab8e71
commit
7bfd67a94f
|
@ -10,6 +10,7 @@
|
|||
#import "MasterViewController.h"
|
||||
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
@ -25,6 +26,15 @@
|
|||
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.
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#import "MasterViewController.h"
|
||||
#import "DetailViewController.h"
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
@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";
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
@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 {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#import "ViewController.h"
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
@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;
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#import "ViewController.h"
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
@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"]];
|
||||
|
|
|
@ -8,10 +8,21 @@
|
|||
|
||||
#import "ExtensionDelegate.h"
|
||||
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
@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 {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
#import "InterfaceController.h"
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
|
||||
|
||||
@interface InterfaceController()
|
||||
|
||||
|
@ -27,7 +25,6 @@
|
|||
[super awakeWithContext:context];
|
||||
|
||||
// Configure interface objects here.
|
||||
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
|
||||
}
|
||||
|
||||
- (void)willActivate {
|
||||
|
|
Loading…
Reference in New Issue