SceneDelegate.m 2.7 KB

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