• 02-更改窗口的根控制器 Demo示例程序源代码


    1. 源代码下载链接:02-更改窗口的根控制器.zip
      18.0 KB
    2. // MJAppDelegate.h

    3. //
    4. //  MJAppDelegate.h
    5. //  02-更改窗口的根控制器
    6. //
    7. //  Created by apple on 13-12-11.
    8. //  Copyright (c) 2013itcast. All rights reserved.
    9. //

    10. #import<UIKit/UIKit.h>

    11. @interfaceMJAppDelegate : UIResponder <UIApplicationDelegate>

    12. @property(strong,nonatomic) UIWindow *window;

    13. @end
    14. // MJAppDelegate.m

      Map
    15. //
    16. //  MJAppDelegate.m
    17. //  02-更改窗口的根控制器
    18. //
    19. //  Created by apple on 13-12-11.
    20. //  Copyright (c) 2013itcast. All rights reserved.
    21. //

    22. #import"MJAppDelegate.h"

    23. #import"MJViewController.h"

    24. @implementationMJAppDelegate

    25. MJViewController *mj;

    26. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    27. {
    28.    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    29.    
    30. //    mj = ;
    31.     MJViewController *haha = [[MJViewController alloc] init];
    32.    
    33.    self.window.rootViewController = haha;
    34.    
    35.     [self.window makeKeyAndVisible];
    36.    returnYES;
    37. }

    38. - (void)applicationWillResignActive:(UIApplication *)application
    39. {
    40.    // 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.
    41.    // 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.
    42. }

    43. - (void)applicationDidEnterBackground:(UIApplication *)application
    44. {
    45.    // 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.
    46.    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    47. }

    48. - (void)applicationWillEnterForeground:(UIApplication *)application
    49. {
    50.    // 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.
    51. }

    52. - (void)applicationDidBecomeActive:(UIApplication *)application
    53. {
    54.    // 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.
    55. }

    56. - (void)applicationWillTerminate:(UIApplication *)application
    57. {
    58.    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    59. }

    60. @end
    61. // MJTwoViewController.h

      Map
    62. //
    63. //  MJTwoViewController.h
    64. //  02-更改窗口的根控制器
    65. //
    66. //  Created by apple on 13-12-11.
    67. //  Copyright (c) 2013itcast. All rights reserved.
    68. //

    69. #import<UIKit/UIKit.h>

    70. @interfaceMJTwoViewController : UIViewController

    71. @end

    72. // MJTwoViewController.m

      Map
    73. //
    74. //  MJTwoViewController.m
    75. //  02-更改窗口的根控制器
    76. //
    77. //  Created by apple on 13-12-11.
    78. //  Copyright (c) 2013itcast. All rights reserved.
    79. //

    80. #import"MJTwoViewController.h"

    81. @interfaceMJTwoViewController ()

    82. @end

    83. @implementationMJTwoViewController

    84. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    85. {
    86.    self= [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    87.    if(self) {
    88.        // Custom initialization
    89.     }
    90.    returnself;
    91. }

    92. - (void)viewDidLoad
    93. {
    94.     [superviewDidLoad];
    95.    // Do any additional setup after loading the view from its nib.
    96. }

    97. - (void)didReceiveMemoryWarning
    98. {
    99.     [superdidReceiveMemoryWarning];
    100.    // Dispose of any resources that can be recreated.
    101. }

    102. @end
    103. // MJViewController.h

      Map
    104. //
    105. //  MJViewController.h
    106. //  02-更改窗口的根控制器
    107. //
    108. //  Created by apple on 13-12-11.
    109. //  Copyright (c) 2013itcast. All rights reserved.
    110. //

    111. #import<UIKit/UIKit.h>

    112. @interfaceMJViewController : UIViewController
    113. - (IBAction)jump2;

    114. @end
    115. // MJViewController.m

      Map
    116. //
    117. //  MJViewController.m
    118. //  02-更改窗口的根控制器
    119. //
    120. //  Created by apple on 13-12-11.
    121. //  Copyright (c) 2013itcast. All rights reserved.
    122. //

    123. #import"MJViewController.h"
    124. #import"MJTwoViewController.h"

    125. @interfaceMJViewController ()

    126. @end

    127. @implementationMJViewController

    128. - (void)dealloc
    129. {
    130.     NSLog(@"MJViewController---挂了");
    131. }

    132. - (IBAction)jump2 {
    133.     MJTwoViewController *two = [[MJTwoViewController alloc] init];
    134.    //本文永久链接,转载请注明出处:http://www.cnblogs.com/ChenYilong/p/3490675.html
    135. //    [UIApplication sharedApplication].keyWindow;
    136.    
    137.    self.view.window.rootViewController = two;
    138.    
    139. //    [self presentViewController:two animated:YES completion:nil];
    140. }
    141. @end

    https://www.evernote.com/shard/s227/sh/cfe13922-d731-4ead-ba0c-5348b08ce0a5/9f0e2c86620dbe8318df1f260bfdbb3a


    作者:
    出处:http://www.cnblogs.com/ChenYilong/(点击RSS订阅)
    本文版权归作者和博客园共有,欢迎转载,
    但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    Auto.js脚本程序控制手机APP
    jemter运行报错,{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","status":415,"traceId":"00-d0eeccb9ae68f44798713724724a4353-4623dc713e44b34c-00"
    解决ModuleNotFoundError: No module named 'pip'问题
    'vue-cli-service' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
    vue配置
    创建分支,提交代码
    Navicat 12.1安装与破解之Navicat Keygen Patch使用方法
    vue--04
    Maven 打包程序如何使用可在外部修改的配置文件
    Vue 2.6 中部分引入 TypeScript 的方法
  • 原文地址:https://www.cnblogs.com/ChenYilong/p/3490675.html
Copyright © 2020-2023  润新知