AppDelegate.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import "AppDelegate.h"
  9. #import "MasterViewController.h"
  10. #import <SDWebImage/SDWebImage.h>
  11. #import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
  12. @implementation AppDelegate
  13. @synthesize window = _window;
  14. @synthesize navigationController = _navigationController;
  15. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  16. {
  17. //Add a custom read-only cache path
  18. NSString *bundledPath = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"CustomPathImages"];
  19. [SDImageCache sharedImageCache].additionalCachePathBlock = ^NSString * _Nullable(NSString * _Nonnull key) {
  20. NSString *fileName = [[SDImageCache sharedImageCache] cachePathForKey:key].lastPathComponent;
  21. return [bundledPath stringByAppendingPathComponent:fileName.stringByDeletingPathExtension];
  22. };
  23. if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) {
  24. // iOS 14 supports WebP built-in
  25. [[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]];
  26. } else {
  27. // iOS 13 does not supports WebP, use third-party codec
  28. [[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
  29. }
  30. if (@available(iOS 13, tvOS 13, macOS 10.15, watchOS 6, *)) {
  31. // For HEIC animated image. Animated image is new introduced in iOS 13, but it contains performance issue for now.
  32. [[SDImageCodersManager sharedManager] addCoder:[SDImageHEICCoder sharedCoder]];
  33. }
  34. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  35. // Override point for customization after application launch.
  36. MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
  37. self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
  38. self.window.rootViewController = self.navigationController;
  39. [self.window makeKeyAndVisible];
  40. return YES;
  41. }
  42. - (void)applicationWillResignActive:(UIApplication *)application
  43. {
  44. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  45. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
  46. }
  47. - (void)applicationDidEnterBackground:(UIApplication *)application
  48. {
  49. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  50. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  51. }
  52. - (void)applicationWillEnterForeground:(UIApplication *)application
  53. {
  54. // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
  55. }
  56. - (void)applicationDidBecomeActive:(UIApplication *)application
  57. {
  58. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
  59. }
  60. - (void)applicationWillTerminate:(UIApplication *)application
  61. {
  62. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  63. }
  64. @end