SceneDelegate.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // SceneDelegate.m
  3. // PDFViewer
  4. //
  5. // Created by kdan on 2022/11/14.
  6. //
  7. #import <ComPDFKit/ComPDFKit.h>
  8. #import "SceneDelegate.h"
  9. #import "CPDFListController.h"
  10. #import "CPDFModel.h"
  11. @interface SceneDelegate ()
  12. @end
  13. @implementation SceneDelegate
  14. - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
  15. // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
  16. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
  17. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
  18. [self setWindow:[[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene]];
  19. [self.window setBackgroundColor:[UIColor whiteColor]];
  20. [self.window makeKeyAndVisible];
  21. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  22. [paths objectAtIndex:0];
  23. CPDFModel *model = [[CPDFModel alloc] init];
  24. model.filePath = [paths objectAtIndex:0];
  25. NSLog(@"%@",model.filePath);
  26. CPDFListController *pdfController = [[CPDFListController alloc] initWithModel:model];
  27. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:pdfController];
  28. pdfController.navigationItem.title = @"Documents";
  29. [self.window setRootViewController:navigationController];
  30. }
  31. - (void)sceneDidDisconnect:(UIScene *)scene {
  32. // Called as the scene is being released by the system.
  33. // This occurs shortly after the scene enters the background, or when its session is discarded.
  34. // Release any resources associated with this scene that can be re-created the next time the scene connects.
  35. // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
  36. }
  37. - (void)sceneDidBecomeActive:(UIScene *)scene {
  38. // Called when the scene has moved from an inactive state to an active state.
  39. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
  40. }
  41. - (void)sceneWillResignActive:(UIScene *)scene {
  42. // Called when the scene will move from an active state to an inactive state.
  43. // This may occur due to temporary interruptions (ex. an incoming phone call).
  44. }
  45. - (void)sceneWillEnterForeground:(UIScene *)scene {
  46. // Called as the scene transitions from the background to the foreground.
  47. // Use this method to undo the changes made on entering the background.
  48. }
  49. - (void)sceneDidEnterBackground:(UIScene *)scene {
  50. // Called as the scene transitions from the foreground to the background.
  51. // Use this method to save data, release shared resources, and store enough scene-specific state information
  52. // to restore the scene back to its current state.
  53. }
  54. @end