02-更改窗口的根控制器 Demo示例程序源代码
2013-12-25 14:47
337 查看
源代码下载链接:
![](https://www.evernote.com/images/file-generic.png)
02-更改窗口的根控制器.zip
18.0 KB
// MJAppDelegate.h |
// MJAppDelegate.h
// 02-更改窗口的根控制器
//
// 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.mMap |
// MJAppDelegate.m
// 02-更改窗口的根控制器
//
// Created by apple on 13-12-11.
// Copyright (c) 2013年itcast. All rights reserved.
//
#import"MJAppDelegate.h"
#import"MJViewController.h"
@implementationMJAppDelegate
MJViewController *mj;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// mj = ;
MJViewController *haha = [[MJViewController alloc] init];
self.window.rootViewController = haha;
[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
// MJTwoViewController.hMap |
// MJTwoViewController.h
// 02-更改窗口的根控制器
//
// Created by apple on 13-12-11.
// Copyright (c) 2013年itcast. All rights reserved.
//
#import<UIKit/UIKit.h>
@interfaceMJTwoViewController : UIViewController
@end
// MJTwoViewController.mMap |
// MJTwoViewController.m
// 02-更改窗口的根控制器
//
// Created by apple on 13-12-11.
// Copyright (c) 2013年itcast. All rights reserved.
//
#import"MJTwoViewController.h"
@interfaceMJTwoViewController ()
@end
@implementationMJTwoViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self= [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self) {
// Custom initialization
}
returnself;
}
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
// MJViewController.hMap |
// MJViewController.h
// 02-更改窗口的根控制器
//
// Created by apple on 13-12-11.
// Copyright (c) 2013年itcast. All rights reserved.
//
#import<UIKit/UIKit.h>
@interfaceMJViewController : UIViewController
- (IBAction)jump2;
@end
// MJViewController.mMap |
// MJViewController.m
// 02-更改窗口的根控制器
//
// Created by apple on 13-12-11.
// Copyright (c) 2013年itcast. All rights reserved.
//
#import"MJViewController.h"
#import"MJTwoViewController.h"
@interfaceMJViewController ()
@end
@implementationMJViewController
- (void)dealloc
{
NSLog(@"MJViewController---挂了");
}
- (IBAction)jump2 {
MJTwoViewController *two = [[MJTwoViewController alloc] init];
//本文永久链接,转载请注明出处:http://www.cnblogs.com/ChenYilong/p/3490675.html
// [UIApplication sharedApplication].keyWindow;
self.view.window.rootViewController = two;
// [self presentViewController:two animated:YES completion:nil];
}
@end
https://www.evernote.com/shard/s227/sh/cfe13922-d731-4ead-ba0c-5348b08ce0a5/9f0e2c86620dbe8318df1f260bfdbb3a
相关文章推荐
- WebSite for Java Developers
- Ajax的工具类AjaxUtils,使用struts返回Json类型
- PHP获取网页内容方法总结
- c# 方法重载的一些事情
- PHP 原生 Session 类库,可完全替代 CI 自己的 Session 类库
- asp.net MVC中form提交和控制…
- asp.net下载文件
- asp.net 把图片RGB格式转换成…
- ASP.NET发送邮件
- asp.net把十六进制转换成十进制
- Asp.Net前台页面如何调用后台cs变…
- java正在表达式代码示例
- AspNetPager控件的用法
- Python 基础编程 数据类型(一)
- java匹配任意字符的正则表达式
- 站立式编程第二天
- C++文件包含处理—#include
- Spring中@Component注解,@Controller注解详解
- ASP.NET MVC3 Model的常用验证示例
- python 简单的多线程链接(二)