UI2_视图切换ViewController
//
// SubViewController.h
// UI2_视图切换
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h> @interface SubViewController : UIViewController @end //
// SubViewController.m
// UI2_视图切换
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "SubViewController.h" @interface SubViewController () @end @implementation SubViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor cyanColor]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(20, 300, self.view.frame.size.width-40, 50);
btn.backgroundColor = [UIColor whiteColor];
[btn setTitle:@"视图切换" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
} - (void)btnClicked
{
NSLog(@"-----");
if (self.view.superview) {
[self.view removeFromSuperview];
}
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
//
// RootViewController.h
// UI2_视图切换
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end //
// RootViewController.m
// UI2_视图切换
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "RootViewController.h"
#import "SubViewController.h" @interface RootViewController ()
{
SubViewController *_svc;
}
@end @implementation RootViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor redColor]; _svc = [[SubViewController alloc] init]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(20, 200, self.view.frame.size.width-40, 50);
[btn setTitle:@"视图切换" forState:UIControlStateNormal];
btn.backgroundColor = [UIColor whiteColor];
[btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
} - (void)btnClicked
{
[self.view addSubview:_svc.view];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
//
// AppDelegate.m
// UI2_视图切换
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "AppDelegate.h"
#import "RootViewController.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
RootViewController *rootViewController = [[RootViewController alloc] init];
self.window.rootViewController = rootViewController;
return YES;
}
UI2_视图切换ViewController的更多相关文章
- UI2_视图切换
// // ViewController.m // UI2_视图切换 // // Created by zhangxueming on 15/7/1. // Copyright (c) 2015年 z ...
- iOS开发系列--视图切换
概述 在iOS开发中视图的切换是很频繁的,独立的视图应用在实际开发过程中并不常见,除非你的应用足够简单.在iOS开发中常用的视图切换有三种,今天我们将一一介绍: UITabBarController ...
- pushViewController addSubview presentModalViewController视图切换
1.pushViewController和popViewController来进行视图切换,首先要确保根视图是NavigationController,不然是不可以用的, pushViewContro ...
- UI3_视图切换
// // ViewController.m // UI3_视图切换 // // Created by zhangxueming on 15/7/3. // Copyright (c) 2015年 z ...
- UI1_ViewController视图切换及Appdelegate
// // ThirdViewController.h // UI1_ViewController视图切换及Appdelegate // // Created by zhangxueming on 1 ...
- Tabbar视图切换,返回上一视图,添加item
前面有一篇博文iOS学习之Tab Bar的使用和视图切换 这是在AppDelegate里使用Tabbar,这样的程序打开就是TabbarView了,有时候我们需要给程序做一些帮助页面,或者登录页面,之 ...
- IPhone多视图切换
处理IPhone多个view切换是我们常遇到的问题,接下来有个比较实用的方法: 而且还附有创建空项目,内存告急处理和动画效果的实现! 具体步骤: 1.创建一个空的项目,然后添加一个ViewContro ...
- iOS:视图切换的第一种方式:模态窗口
一.UIModalController:模态窗口(一个控制器模态出另一个控制器的模态窗口) 当我们在view controller A中模态显示view controller B的时候,A就充当pre ...
- ios 视图切换翻页效果
本文写的是视图切换,涉及到的内容有 1.实现代码添加Navigation Bar Toolbal: 2.实现在Navigation Bar和Toolbar上用代码添加Bar Button Item: ...
随机推荐
- innobackupex的备份和恢复
http://blog.itpub.net/15480802/viewspace-1173479/ 1 原理 分3个阶段:备份backup – 预恢复prepare -- 恢复restore 注 ...
- 云服务器 ECS Linux 服务器修改时区的两种方式
在云服务器 ECS Linux 系统中,以 Centos6.5 为例,可以通过如下两种方式,修改系统时区: 可以使用命令 tzselect,修改时区.操作示例: [root@localhost ~]# ...
- jquery批量设置属性readonly和disabled
分享下Jquery的api中对元素应用disabled和readonly属性的方法. 1,readonly 属性设置 $('input').attr("readonly",&quo ...
- 一款基于jQuery饼状图比例分布数据报表
今天给大家带来一款基于jQuery饼状图比例分布数据报表.这款报表插件适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之窗.效果图如下: 在线预览 ...
- STC51系列单片机免掉电下载(热启动下载)
相信喜欢单片机的朋友都用过STC的单片机,用过STC单片机的朋友都有这种感受:实惠.易用.功能强大!就是每次下载都要冷启动特别恶心,相信很多朋友的开发板上的电源键都按烂了. 其实STC单片机可以不用免 ...
- php连接数据库时候的字符集设置
最好的办法:设置mysql服务器的字符集,当然也可以通过mysql提供的api来设置运行时的字符集 Ideally a proper character set will be set at the ...
- Maven-编译打包
1. 打包时忽略测试阶段 mvn clean mvn package -DskipTests
- DIH
DIH内存溢出: 在使用DIH时,容易报内存溢出错误.可以通过设置jvm大小来解决.设置方法如下: 在tomcat\bin\startup.bat 加入SET JAVA_OPTS=-Xms128m - ...
- 【Mood-3】心声
每天醒来,我都会想明白一件事情,时间是不会停下来的,如果打算活下去的话,那么我们会有25岁,会有30岁,更会有40岁,为了不让时间风干我的理想,未来只剩下抱怨,那么为明天伏笔,今天只有努力.耸耸背上行 ...
- ios菜鸟总结2
这个星期学起oc来可能是最纠结的.话不多说先补充一下上一个星期的快捷键吧.工程导航器:Command+1 显示/隐藏导航器面板:Command+0 .显示/隐藏实用工具面板:Command+Op ...