UIViewController
来源:互联网 发布:淘宝店铺海报尺寸 编辑:程序博客网 时间:2024/06/07 05:05
/***********************************************************************************/
#import "AppDelegate.h"
#import "RootViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
-(void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window =[[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];
// self.window.backgroundColor =[UIColor redColor];
self.window.backgroundColor =[[UIColoralloc] initWithPatternImage:[UIImageimageNamed:@"/Users/dllo/Desktop/UI/UI03_UIViewController/UI03_UIViewController/sdfsdf.jpg"]];
[self.windowmakeKeyAndVisible];
[_window release];
///Xcode 7.0之后,所有的工程必须指定跟视图控制器,所以我们创建了一个ViewController的子类,然后把这个子类创建的对象指定为根视图控制器
///UIViewController这个类不能向button一样直接去使用,如果要用只能创建他的子类去使用
RootViewController *rooVc =[[RootViewControlleralloc] init];
NSLog(@"%s",__FUNCTION__);
self.window.rootViewController =rooVc;
[rooVc release];
return YES;
}
/////////////////////////////////////
#import "RootViewController.h"
#import "SecondViewControlle.h"
@interface RootViewController ()
@property(nonatomic,retain)NSMutableArray *arr;
@property(nonatomic,retain)NSMutableDictionary *dic;
@end
@implementation RootViewController
//1.这个方法系统会自己调用,是他自己的初始化方法,一般在这个方法里对一些容器的属性进行初始化使用
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
NSLog(@"%s",__FUNCTION__);
///容器属性在使用之前必须要进行初始化方法
self.arr =[NSMutableArrayarray];
}
return self;
}
-(void)loadView
{
[super loadView];
NSLog(@"%s",__FUNCTION__);
//2.如果重写父类的方法,如果要保证原功能不变,需要通过关键字super去调用父类的方法,这样父类的方法就会实现对应的功能,只需要在子类的放发写额外功能即可
// 作用就是对self.view进行加载
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"%s",__FUNCTION__);
// 4.执行到这个方法的时候,viewdidlod方法已经执行结束,视图已经创建好了,将要出现在屏幕上
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"%s",__FUNCTION__);
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
NSLog(@"%s",__FUNCTION__);
}
-(void)viewDidDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
NSLog(@"%s",__FUNCTION__);
}
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
//3.执行到这个方法的时候.self.view已经加载好了,我们可以再放这里进行试图的创建,然后把师徒放到self.view上区显示
NSLog(@"%s",__FUNCTION__);
/// 视图控制器会自动创建一个透明的view,一般来讲需要先给self.view设置一个白色的背景色
/// 视图设置器也是以后最常用的,一般代码都在试图控制器内
// self.view.backgroundColor =[UIColor yellowColor];
self.view.backgroundColor =[[UIColoralloc] initWithPatternImage:[UIImage imageNamed:@"/Users/dllo/Desktop/UI/UI03_UIViewController/UI03_UIViewController/sdfsdf.jpg"]];
// UIButton *button =[UIButton buttonWithType:UIButtonTypeSystem];
// button.frame =CGRectMake(100, 100, 150, 50);
// button.backgroundColor =[UIColor redColor];
// [self.view addSubview:button];
// //标题弧度 边框绑定一个点击方法
// [button setTitle:@"开始" forState:UIControlStateNormal];
// button.layer.borderWidth =1;
// button.layer.cornerRadius =25;
// [button addTarget:self action:@selector(cile:) forControlEvents:UIControlEventTouchUpInside];
UIButton *button =[UIButton buttonWithType:UIButtonTypeSystem];
button.frame=CGRectMake(0,0, 2,2 );
button.backgroundColor =[UIColorwhiteColor];
button.layer.borderWidth =1;
button.layer.cornerRadius=25;
[self.viewaddSubview:button];
[button setTitle:@"开始"forState:UIControlStateNormal];
[button addTarget:selfaction:@selector(cile:)forControlEvents:UIControlEventTouchUpInside];
}
-(void)cile:(UIButton *)button
{
///模态跳转
/// 1.先创建一个下一个对象
SecondViewControlle *secVc =[[SecondViewControllealloc] init];
/// 2.设置跳转的动画效果
[secVc setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
///3.跳转
[selfpresentViewController:secVc animated:YEScompletion:^{
}];
/// 4.内存
[secVc release];
}
/////////////////////////////////#import "SecondViewControlle.h"
@interface SecondViewControlle ()
@end
@implementation SecondViewControlle
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
// self.view.backgroundColor =[UIColor grayColor];
self.view.backgroundColor =[[UIColoralloc] initWithPatternImage:[UIImageimageNamed:@"/Users/dllo/Desktop/UI/UI03_UIViewController/UI03_UIViewController/asdasd.jpg"]];
///标题是返回,边框,弧度,点击方法
UIButton *button =[UIButtonbuttonWithType:UIButtonTypeSystem];
button.frame=CGRectMake(100,100, 150, 50);
button.backgroundColor =[UIColororangeColor];
[self.viewaddSubview:button];
[button setTitle:@"返回"forState:UIControlStateNormal];
button.layer.borderWidth =1;
button.layer.cornerRadius =25;
[button addTarget:selfaction:@selector(cile:)forControlEvents:UIControlEventTouchUpInside];
}
-(void)cile:(UIButton *)button
{
///返回
[selfdismissViewControllerAnimated:YEScompletion:^{
}];
}
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- 单例模式【Singleton Pattern 】
- snmpwalk命令常用方法
- 感知哈希算法(Perceptual hash algorithm)
- XMPP
- Quartz的使用及与spring集成使用
- UIViewController
- java 集成hibernate valitator校验
- Python 的OS 模块(一)
- Android之菜单选项子菜单submenu(二)
- 创建型:设计模式之工厂模式(一)
- GC算法精解(复制算法与标记/整理算法) 目前的两种主流算法,基于标记清除算法而来
- ExtJs树展开到指定节点
- Flask中session的用法
- jeecms修改端口号