UIViewController
2015-12-24 14:35
615 查看
/***********************************************************************************/
#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 =[[UIWindow
alloc] initWithFrame:[[UIScreen
mainScreen] bounds]];
// self.window.backgroundColor =[UIColor redColor];
self.window.backgroundColor
=[[UIColor
alloc]
initWithPatternImage:[UIImage
imageNamed:@"/Users/dllo/Desktop/UI/UI03_UIViewController/UI03_UIViewController/sdfsdf.jpg"]];
[self.window
makeKeyAndVisible];
[_window release];
///Xcode 7.0之后,所有的工程必须指定跟视图控制器,所以我们创建了一个ViewController的子类,然后把这个子类创建的对象指定为根视图控制器
///UIViewController这个类不能向button一样直接去使用,如果要用只能创建他的子类去使用
RootViewController *rooVc =[[RootViewController
alloc]
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 = [super
initWithNibName:nibNameOrNil
bundle:nibBundleOrNil];
if (self)
{
NSLog(@"%s",__FUNCTION__);
///容器属性在使用之前必须要进行初始化方法
self.arr =[NSMutableArray
array];
}
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 {
[super
viewDidLoad];
// 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
=[[UIColor
alloc]
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 =[UIColor
whiteColor];
button.layer.borderWidth =1;
button.layer.cornerRadius=25;
[self.view
addSubview:button];
[button setTitle:@"开始"
forState:UIControlStateNormal];
[button addTarget:self
action:@selector(cile:)
forControlEvents:UIControlEventTouchUpInside];
}
-(void)cile:(UIButton *)button
{
///模态跳转
/// 1.先创建一个下一个对象
SecondViewControlle *secVc =[[SecondViewControlle
alloc]
init];
/// 2.设置跳转的动画效果
[secVc setModalTransitionStyle:
UIModalTransitionStyleFlipHorizontal];
///3.跳转
[self
presentViewController:secVc animated:YES
completion:^{
}];
/// 4.内存
[secVc release];
}
/////////////////////////////////
#import "SecondViewControlle.h"
@interface
SecondViewControlle ()
@end
@implementation SecondViewControlle
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view.
// self.view.backgroundColor =[UIColor grayColor];
self.view.backgroundColor
=[[UIColor
alloc]
initWithPatternImage:[UIImage
imageNamed:@"/Users/dllo/Desktop/UI/UI03_UIViewController/UI03_UIViewController/asdasd.jpg"]];
///标题是返回,边框,弧度,点击方法
UIButton *button =[UIButton
buttonWithType:UIButtonTypeSystem];
button.frame=CGRectMake(100,
100, 150,
50);
button.backgroundColor =[UIColor
orangeColor];
[self.view
addSubview:button];
[button setTitle:@"返回"
forState:UIControlStateNormal];
button.layer.borderWidth =1;
button.layer.cornerRadius =25;
[button addTarget:self
action:@selector(cile:)
forControlEvents:UIControlEventTouchUpInside];
}
-(void)cile:(UIButton *)button
{
///返回
[self
dismissViewControllerAnimated:YES
completion:^{
}];
}
#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 =[[UIWindow
alloc] initWithFrame:[[UIScreen
mainScreen] bounds]];
// self.window.backgroundColor =[UIColor redColor];
self.window.backgroundColor
=[[UIColor
alloc]
initWithPatternImage:[UIImage
imageNamed:@"/Users/dllo/Desktop/UI/UI03_UIViewController/UI03_UIViewController/sdfsdf.jpg"]];
[self.window
makeKeyAndVisible];
[_window release];
///Xcode 7.0之后,所有的工程必须指定跟视图控制器,所以我们创建了一个ViewController的子类,然后把这个子类创建的对象指定为根视图控制器
///UIViewController这个类不能向button一样直接去使用,如果要用只能创建他的子类去使用
RootViewController *rooVc =[[RootViewController
alloc]
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 = [super
initWithNibName:nibNameOrNil
bundle:nibBundleOrNil];
if (self)
{
NSLog(@"%s",__FUNCTION__);
///容器属性在使用之前必须要进行初始化方法
self.arr =[NSMutableArray
array];
}
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 {
[super
viewDidLoad];
// 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
=[[UIColor
alloc]
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 =[UIColor
whiteColor];
button.layer.borderWidth =1;
button.layer.cornerRadius=25;
[self.view
addSubview:button];
[button setTitle:@"开始"
forState:UIControlStateNormal];
[button addTarget:self
action:@selector(cile:)
forControlEvents:UIControlEventTouchUpInside];
}
-(void)cile:(UIButton *)button
{
///模态跳转
/// 1.先创建一个下一个对象
SecondViewControlle *secVc =[[SecondViewControlle
alloc]
init];
/// 2.设置跳转的动画效果
[secVc setModalTransitionStyle:
UIModalTransitionStyleFlipHorizontal];
///3.跳转
[self
presentViewController:secVc animated:YES
completion:^{
}];
/// 4.内存
[secVc release];
}
/////////////////////////////////
#import "SecondViewControlle.h"
@interface
SecondViewControlle ()
@end
@implementation SecondViewControlle
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view.
// self.view.backgroundColor =[UIColor grayColor];
self.view.backgroundColor
=[[UIColor
alloc]
initWithPatternImage:[UIImage
imageNamed:@"/Users/dllo/Desktop/UI/UI03_UIViewController/UI03_UIViewController/asdasd.jpg"]];
///标题是返回,边框,弧度,点击方法
UIButton *button =[UIButton
buttonWithType:UIButtonTypeSystem];
button.frame=CGRectMake(100,
100, 150,
50);
button.backgroundColor =[UIColor
orangeColor];
[self.view
addSubview:button];
[button setTitle:@"返回"
forState:UIControlStateNormal];
button.layer.borderWidth =1;
button.layer.cornerRadius =25;
[button addTarget:self
action:@selector(cile:)
forControlEvents:UIControlEventTouchUpInside];
}
-(void)cile:(UIButton *)button
{
///返回
[self
dismissViewControllerAnimated:YES
completion:^{
}];
}
相关文章推荐
- 【android学习】关于textview.setEllipsize(TextUtils.TruncateAt.valueOf("END"));失效
- 类似UC天气下拉和微信下拉眼睛头部弹入淡出UI交互效果(开源项目)。
- UILTview
- UITextField和lUIButton结合
- UITextField
- 转载:设置UIImage的渲染模式:UIImage.renderingMode
- UIButton
- UE4无尽跑酷游戏制作杂记之一
- ueditor使用小结
- 动态调整UITableViewCell的高度
- mysql_escape_string — 转义一个字符串用于 mysql_query
- iOS开发系列之三 - UITextField 使用方法小结
- UIdynamic的简单使用
- Android如何通过gradientui类库实现渐变切换icon效果
- UICollectionViewLayout
- UITextField
- iOS 多样式UILabel
- Poj 1276 Common Subsequence
- Leetcode: Closest Binary Search Tree Value II
- UI学习