01-modal Demo示例程序源代码
2024-09-03 20:24:08
- 源代码下载链接:01-modal.zip
37.8 KB // MJAppDelegate.h
- //
- // MJAppDelegate.h
- // 01-modal
- //
- // Created by apple on 13-12-11.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceMJAppDelegate : UIResponder <UIApplicationDelegate>
- @property(strong,nonatomic) UIWindow *window;
- @end
// MJAppDelegate.m
- //
- // MJAppDelegate.m
- // 01-modal
- //
- // Created by apple on 13-12-11.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"MJAppDelegate.h"
- #import"MJOneViewController.h"
- @implementationMJAppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- self.window.rootViewController = [[MJOneViewController alloc] init];
- [self.window makeKeyAndVisible];
- returnYES;
- }
- - (void)applicationWillResignActive:(UIApplication *)application
- {
- // 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.
- // 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.
- }
- - (void)applicationDidEnterBackground:(UIApplication *)application
- {
- // 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.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
- }
- - (void)applicationWillEnterForeground:(UIApplication *)application
- {
- // 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.
- }
- - (void)applicationDidBecomeActive:(UIApplication *)application
- {
- // 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.
- }
- - (void)applicationWillTerminate:(UIApplication *)application
- {
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
- }
- @end
// MJOneViewController.h
- //
- // MJOneViewController.h
- // 01-modal
- //
- // Created by apple on 13-12-11.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceMJOneViewController : UIViewController
- - (IBAction)jump2;
- @end
// MJOneViewController.m
- //
- // MJOneViewController.m
- // 01-modal
- //
- // Created by apple on 13-12-11.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"MJOneViewController.h"
- #import"MJTwoViewController.h"
- #import"MJThreeViewController.h"
- @interfaceMJOneViewController ()
- @end
- @implementationMJOneViewController
- //- (IBAction)jump2 {
- // MJTwoViewController *two = [[MJTwoViewController alloc] init];
- //
- // // modalTransitionStyle设置模态控制器展示的形式
- // /*
- // UIModalTransitionStyleCoverVertical = 0, 垂直覆盖(从底部钻上来)
- // UIModalTransitionStyleFlipHorizontal, 水平翻转
- // UIModalTransitionStyleCrossDissolve, 淡入淡出
- // UIModalTransitionStylePartialCurl 翻页(展示部分界面)
- // */
- //// two.modalTransitionStyle = UIModalTransitionStylePartialCurl;
- ////本文永久链接,转载请注明出处:http://www.cnblogs.com/ChenYilong/p/3490807.html
- // //以modal形式展示其他控制器(模态窗口)
- // [self presentViewController:two animated:YES completion:^{
- // NSLog(@"----展示完毕");
- // }];
- //}
- /*
- 给一个控制器顶部增加一个导航栏的最快方法:
- 1>给这个控制器包装一个导航控制器(UINavigationController)
- */
- - (void)jump2
- {
- MJThreeViewController *three = [[MJThreeViewController alloc] init];
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:three];
- nav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
- NSLog(@"前:one = %p, window的子控件%@",self.view, [UIApplication sharedApplication].keyWindow.subviews);
- [selfpresentViewController:nav animated:YEScompletion:^{
- NSLog(@"后:nav=%p, %@", nav.view, [UIApplication sharedApplication].keyWindow.subviews);
- }];
- }
- @end
// MJTwoViewController.h
- //
- // MJTwoViewController.h
- // 01-modal
- //
- // Created by apple on 13-12-11.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interfaceMJTwoViewController : UIViewController
- - (IBAction)cancel:(id)sender;
- @end
// MJTwoViewController.m
- //
- // MJTwoViewController.m
- // 01-modal
- //
- // Created by apple on 13-12-11.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"MJTwoViewController.h"
- @interfaceMJTwoViewController ()
- @end
- @implementationMJTwoViewController
- - (void)viewDidLoad
- {
- [superviewDidLoad];
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
- btn.frame = CGRectMake(0,44,40,40);
- [self.view addSubview:btn];
- }
- - (IBAction)cancel:(id)sender {
- //关闭当前的模态控制器
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- @end
// MJThreeViewController.h
- //
- // MJThreeViewController.h
- // 01-modal
- //
- // Created by apple on 13-12-11.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import<UIKit/UIKit.h>
- @interface MJThreeViewController : UIViewController
- @end
// MJThreeViewController.m
- //
- // MJThreeViewController.m
- // 01-modal
- //
- // Created by apple on 13-12-11.
- // Copyright (c) 2013年itcast. All rights reserved.
- //
- #import"MJThreeViewController.h"
- @interface MJThreeViewController ()
- @end
- @implementationMJThreeViewController
- - (void)viewDidLoad
- {
- [superviewDidLoad];
- UIView *abc = [[UIView alloc] init];
- abc.frame = CGRectMake(0,0,100,100);
- abc.backgroundColor = [UIColor yellowColor];
- [self.view addSubview:abc];
- //本文永久链接,转载请注明出处:http://www.cnblogs.com/ChenYilong/p/3490807.html
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消"style:UIBarButtonItemStyleBordered target:selfaction:@selector(cancel)];
- }
- - (void)cancel
- {
- [selfdismissViewControllerAnimated:YEScompletion:nil];
- }
- @end
最新文章
- 借助JavaScript中的Dom属性改变Html中Table边框的颜色
- SqlBulkCopy
- 判断闰年的方法以及如何获得单链表的倒数第K个元素
- C#基础-Func,Action
- Google发布SSLv3漏洞简要分析报告
- openURL的使用方法
- bzoj 1264 [AHOI2006]基因匹配Match(DP+树状数组)
- Android VideoView
- JAVA为什么会空指针异常
- android下文件下载
- angularJS的环境搭建--初学
- Hadoop 2.2.0单节点的伪分布集成环境搭建
- [Linux] host dig nslookup查询域名的DNS解析
- Python3-高阶函数、闭包
- [转]git commit --amend用法
- UVALive 5135 Mining Your Own Bussiness【tarjan点双】
- UGUI——重写Image类实现进度条
- 20155220 2016-2017-2 《java程序设计》第二周学习总结
- LeetCode 36. Valid Sudoku (C++)
- Java面试中常问的Spring方面问题(涵盖七大方向共55道题,含答案)
热门文章
- C#属性默认值设置
- 『JavaScript』核心
- Linux 文件属性及修改权限
- 西门子S7-200 SMART在win10环境下,使用虚拟机进行网络通信问题一二
- 深度学习-CNN tensorflow 可视化
- 给移动硬盘安装rhel7
- 总结java操作MySQL 即JDBC的使用
- 测试理论--branch testing and boundary testing
- perf 对两个map是否重叠的判断,以及函数map_groups__fixup_overlappings代码逻辑
- 【转】Win7装不上Office2010 提示MSXML 6.10.1129.0