1. 源代码下载链接:01-modal.zip
    37.8 KB
  2. // MJAppDelegate.h

  3. //
  4. //  MJAppDelegate.h
  5. //  01-modal
  6. //
  7. //  Created by apple on 13-12-11.
  8. //  Copyright (c) 2013年itcast. 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. //  01-modal
  18. //
  19. //  Created by apple on 13-12-11.
  20. //  Copyright (c) 2013年itcast. All rights reserved.
  21. //
  22. #import"MJAppDelegate.h"
  23. #import"MJOneViewController.h"
  24. @implementationMJAppDelegate
  25. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  26. {
  27.    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  28.    
  29.    self.window.rootViewController = [[MJOneViewController alloc] init];
  30.    
  31.     [self.window makeKeyAndVisible];
  32.    returnYES;
  33. }
  34. - (void)applicationWillResignActive:(UIApplication *)application
  35. {
  36.    // 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.
  37.    // 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.
  38. }
  39. - (void)applicationDidEnterBackground:(UIApplication *)application
  40. {
  41.    // 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.
  42.    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  43. }
  44. - (void)applicationWillEnterForeground:(UIApplication *)application
  45. {
  46.    // 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.
  47. }
  48. - (void)applicationDidBecomeActive:(UIApplication *)application
  49. {
  50.    // 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.
  51. }
  52. - (void)applicationWillTerminate:(UIApplication *)application
  53. {
  54.    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  55. }
  56. @end
  57. // MJOneViewController.h

    Map

  58. //
  59. //  MJOneViewController.h
  60. //  01-modal
  61. //
  62. //  Created by apple on 13-12-11.
  63. //  Copyright (c) 2013年itcast. All rights reserved.
  64. //
  65. #import<UIKit/UIKit.h>
  66. @interfaceMJOneViewController : UIViewController
  67. - (IBAction)jump2;
  68. @end
  69. // MJOneViewController.m

    Map

  70. //
  71. //  MJOneViewController.m
  72. //  01-modal
  73. //
  74. //  Created by apple on 13-12-11.
  75. //  Copyright (c) 2013年itcast. All rights reserved.
  76. //
  77. #import"MJOneViewController.h"
  78. #import"MJTwoViewController.h"
  79. #import"MJThreeViewController.h"
  80. @interfaceMJOneViewController ()
  81. @end
  82. @implementationMJOneViewController
  83. //- (IBAction)jump2 {
  84. //    MJTwoViewController *two = [[MJTwoViewController alloc] init];
  85. //   
  86. //    // modalTransitionStyle设置模态控制器展示的形式
  87. //    /*
  88. //     UIModalTransitionStyleCoverVertical = 0, 垂直覆盖(从底部钻上来)
  89. //     UIModalTransitionStyleFlipHorizontal, 水平翻转
  90. //     UIModalTransitionStyleCrossDissolve,  淡入淡出
  91. //     UIModalTransitionStylePartialCurl     翻页(展示部分界面)
  92. //     */
  93. ////    two.modalTransitionStyle = UIModalTransitionStylePartialCurl;
  94. ////本文永久链接,转载请注明出处:http://www.cnblogs.com/ChenYilong/p/3490807.html   
  95. //    //以modal形式展示其他控制器(模态窗口)
  96. //    [self presentViewController:two animated:YES completion:^{
  97. //        NSLog(@"----展示完毕");
  98. //    }];
  99. //}
  100. /*
  101.  给一个控制器顶部增加一个导航栏的最快方法:
  102.  1>给这个控制器包装一个导航控制器(UINavigationController)
  103.  */
  104. - (void)jump2
  105. {
  106.     MJThreeViewController *three = [[MJThreeViewController alloc] init];
  107.    
  108.     UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:three];
  109.    
  110.     nav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  111.    
  112.     NSLog(@"前:one = %p, window的子控件%@",self.view, [UIApplication sharedApplication].keyWindow.subviews);
  113.    
  114.     [selfpresentViewController:nav animated:YEScompletion:^{
  115.         NSLog(@"后:nav=%p, %@", nav.view, [UIApplication sharedApplication].keyWindow.subviews);
  116.     }];
  117. }
  118. @end
  119. // MJTwoViewController.h

    Map

  120. //
  121. //  MJTwoViewController.h
  122. //  01-modal
  123. //
  124. //  Created by apple on 13-12-11.
  125. //  Copyright (c) 2013年itcast. All rights reserved.
  126. //
  127. #import<UIKit/UIKit.h>
  128. @interfaceMJTwoViewController : UIViewController
  129. - (IBAction)cancel:(id)sender;
  130. @end
  131. // MJTwoViewController.m

    Map

  132. //
  133. //  MJTwoViewController.m
  134. //  01-modal
  135. //
  136. //  Created by apple on 13-12-11.
  137. //  Copyright (c) 2013年itcast. All rights reserved.
  138. //
  139. #import"MJTwoViewController.h"
  140. @interfaceMJTwoViewController ()
  141. @end
  142. @implementationMJTwoViewController
  143. - (void)viewDidLoad
  144. {
  145.     [superviewDidLoad];
  146.    
  147.     UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
  148.     btn.frame = CGRectMake(0,44,40,40);
  149.     [self.view addSubview:btn];
  150. }
  151. - (IBAction)cancel:(id)sender {
  152.    //关闭当前的模态控制器
  153.     [self dismissViewControllerAnimated:YES completion:nil];
  154. }
  155. @end
  156. // MJThreeViewController.h

    Map

  157. //
  158. //  MJThreeViewController.h
  159. //  01-modal
  160. //
  161. //  Created by apple on 13-12-11.
  162. //  Copyright (c) 2013年itcast. All rights reserved.
  163. //
  164. #import<UIKit/UIKit.h>
  165. @interface MJThreeViewController : UIViewController
  166. @end
  167. // MJThreeViewController.m

    Map

  168. //
  169. //  MJThreeViewController.m
  170. //  01-modal
  171. //
  172. //  Created by apple on 13-12-11.
  173. //  Copyright (c) 2013年itcast. All rights reserved.
  174. //
  175. #import"MJThreeViewController.h"
  176. @interface MJThreeViewController ()
  177. @end
  178. @implementationMJThreeViewController
  179. - (void)viewDidLoad
  180. {
  181.     [superviewDidLoad];
  182.    
  183.     UIView *abc = [[UIView alloc] init];
  184.     abc.frame = CGRectMake(0,0,100,100);
  185.     abc.backgroundColor = [UIColor yellowColor];
  186.     [self.view addSubview:abc];
  187.    //本文永久链接,转载请注明出处:http://www.cnblogs.com/ChenYilong/p/3490807.html
  188.    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消"style:UIBarButtonItemStyleBordered target:selfaction:@selector(cancel)];
  189. }
  190. - (void)cancel
  191. {
  192.     [selfdismissViewControllerAnimated:YEScompletion:nil];
  193. }
  194. @end

最新文章

  1. 借助JavaScript中的Dom属性改变Html中Table边框的颜色
  2. SqlBulkCopy
  3. 判断闰年的方法以及如何获得单链表的倒数第K个元素
  4. C#基础-Func,Action
  5. Google发布SSLv3漏洞简要分析报告
  6. openURL的使用方法
  7. bzoj 1264 [AHOI2006]基因匹配Match(DP+树状数组)
  8. Android VideoView
  9. JAVA为什么会空指针异常
  10. android下文件下载
  11. angularJS的环境搭建--初学
  12. Hadoop 2.2.0单节点的伪分布集成环境搭建
  13. [Linux] host dig nslookup查询域名的DNS解析
  14. Python3-高阶函数、闭包
  15. [转]git commit --amend用法
  16. UVALive 5135 Mining Your Own Bussiness【tarjan点双】
  17. UGUI——重写Image类实现进度条
  18. 20155220 2016-2017-2 《java程序设计》第二周学习总结
  19. LeetCode 36. Valid Sudoku (C++)
  20. Java面试中常问的Spring方面问题(涵盖七大方向共55道题,含答案)

热门文章

  1. C#属性默认值设置
  2. 『JavaScript』核心
  3. Linux 文件属性及修改权限
  4. 西门子S7-200 SMART在win10环境下,使用虚拟机进行网络通信问题一二
  5. 深度学习-CNN tensorflow 可视化
  6. 给移动硬盘安装rhel7
  7. 总结java操作MySQL 即JDBC的使用
  8. 测试理论--branch testing and boundary testing
  9. perf 对两个map是否重叠的判断,以及函数map_groups__fixup_overlappings代码逻辑
  10. 【转】Win7装不上Office2010 提示MSXML 6.10.1129.0