iOS UI 02 UIimageview 和模态切换
2015-12-13 15:46
316 查看
注意这是哪一个文件!!!RootViewController.m
// RootViewController.m
// Ui03 - UIimageView
//
// Created by dllo on 15/11/10.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "RootViewController.h"
#import "RootView.h"
#import "SecondViewController.h"
@interface
RootViewController ()
@end
@implementation RootViewController
//ViewController的初始化方法
//- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
// self = [super initWithNibName: bundle:];
// if (self) {
//
// }
// return self;
//}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"nihao");
}
- (void)viewDidLoad {
[super
viewDidLoad];
self.view.backgroundColor = [UIColor
whiteColor];
RootView *rootV = [[RootView
alloc]initWithFrame:[[UIScreen
mainScreen] bounds] ];
[self.view
addSubview:rootV];
[rootV release];
UIButton *button = [UIButton
buttonWithType:UIButtonTypeCustom];
button.frame =
CGRectMake(150, 150, 150, 150);
button.backgroundColor = [UIColor
redColor];
[button addTarget:self
action:@selector(buttonAction)
forControlEvents:UIControlEventTouchDragInside];
[self.view
addSubview:button];
NSLog(@"a");
//UIImage - 专门用来管理图片的类,本身不具备显示功能
//UIImageView-
专门用来显示图片的视图
//添加图片的2中方法
//1
// UIImage *image = [UIImage imageNamed:@"image4.jpg"];
// UIImageView *imagev = [[ UIImageView alloc]initWithImage:image];
// imagev.frame = self.view.frame;
// [self.view addSubview:imagev];
// [imagev release];
//2
常用
// UIImageView *imagev = [[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 300, 500)];
// imagev.image = [UIImage imageNamed:@"image9.jpg"];
// [self.view addSubview:imagev];
// [imagev release];
// Do any additional setup after loading the view.
}
- (void)buttonAction
{
//三下回车
秘诀 选中最后一组,敲3次回车
SecondViewController *secondVC = [[SecondViewController
alloc]init];
//切换页面
//参数1,
要切换的界面
//参数2,
是否需要动画特效
//参数3 , block -
[self
presentViewController:secondVC animated:YES
completion:^{
//切换完成调用
// NSLog(@"%d", __LINE__);
}];
//presentViewController会引起引用计数增加
// NSLog(@"%ld", secondVC.retainCount);
//先执行完成此方法(buttonAction),再去切换界面
// NSLog(@"%d", __LINE__);
[secondVC release];
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
NSLog(@"接受内存告警");
// 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
//
// SecondViewController.m
// Ui03 - UIimageView
//
// Created by dllo on 15/11/10.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "SecondViewController.h"
@interface
SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.view.backgroundColor = [UIColor
greenColor];
UIButton *button = [UIButton
buttonWithType:UIButtonTypeCustom];
button.frame =
CGRectMake(150, 150, 150, 150);
button.backgroundColor = [UIColor
redColor];
[button addTarget:self
action:@selector(buttonAction)
forControlEvents:UIControlEventTouchDragInside];
[self.view
addSubview:button];
NSLog(@"bbb");
// Do any additional setup after loading the view.
}
- (void)buttonAction
{
//切回原来界面
//参数1 -
是否需要动画
//参数2 - block-
切换完成调用
//注意新建的rootVc的方式是切换到新的rootVC界面,而非切回原来的rootVC界面
[self
dismissViewControllerAnimated:YES
completion:^{
//NSLog(@"%d", __LINE__);
}];
// NSLog(@"%d", __LINE__);
}
- (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
//
// RootView.m
// Ui03 - UIimageView
//
// Created by dllo on 15/11/10.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "RootView.h"
@implementation RootView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
[self
createSubviews];
}
return
self;
}
- (void)createSubviews
{
//UIImage - 专门用来管理图片的类,本身不具备显示功能
//UIImageView-
专门用来显示图片的视图
//添加图片的2中方法
//1
// UIImage *image = [UIImage imageNamed:@"image4.jpg"];
// UIImageView *imagev = [[ UIImageView alloc]initWithImage:image];
// imagev.frame = self.view.frame;
// [self.view addSubview:imagev];
// [imagev release];
//2
常用
self.backgroundColor = [UIColor
whiteColor];
UIImageView *imagev = [[UIImageView
alloc]initWithFrame:CGRectMake(30, 30, 300,500)];
imagev.image = [UIImage
imageNamed:@"image9.jpg"];
[self addSubview:imagev];
[imagev release];
}
@end
// RootViewController.m
// Ui03 - UIimageView
//
// Created by dllo on 15/11/10.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "RootViewController.h"
#import "RootView.h"
#import "SecondViewController.h"
@interface
RootViewController ()
@end
@implementation RootViewController
//ViewController的初始化方法
//- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
// self = [super initWithNibName: bundle:];
// if (self) {
//
// }
// return self;
//}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"nihao");
}
- (void)viewDidLoad {
[super
viewDidLoad];
self.view.backgroundColor = [UIColor
whiteColor];
RootView *rootV = [[RootView
alloc]initWithFrame:[[UIScreen
mainScreen] bounds] ];
[self.view
addSubview:rootV];
[rootV release];
UIButton *button = [UIButton
buttonWithType:UIButtonTypeCustom];
button.frame =
CGRectMake(150, 150, 150, 150);
button.backgroundColor = [UIColor
redColor];
[button addTarget:self
action:@selector(buttonAction)
forControlEvents:UIControlEventTouchDragInside];
[self.view
addSubview:button];
NSLog(@"a");
//UIImage - 专门用来管理图片的类,本身不具备显示功能
//UIImageView-
专门用来显示图片的视图
//添加图片的2中方法
//1
// UIImage *image = [UIImage imageNamed:@"image4.jpg"];
// UIImageView *imagev = [[ UIImageView alloc]initWithImage:image];
// imagev.frame = self.view.frame;
// [self.view addSubview:imagev];
// [imagev release];
//2
常用
// UIImageView *imagev = [[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 300, 500)];
// imagev.image = [UIImage imageNamed:@"image9.jpg"];
// [self.view addSubview:imagev];
// [imagev release];
// Do any additional setup after loading the view.
}
- (void)buttonAction
{
//三下回车
秘诀 选中最后一组,敲3次回车
SecondViewController *secondVC = [[SecondViewController
alloc]init];
//切换页面
//参数1,
要切换的界面
//参数2,
是否需要动画特效
//参数3 , block -
[self
presentViewController:secondVC animated:YES
completion:^{
//切换完成调用
// NSLog(@"%d", __LINE__);
}];
//presentViewController会引起引用计数增加
// NSLog(@"%ld", secondVC.retainCount);
//先执行完成此方法(buttonAction),再去切换界面
// NSLog(@"%d", __LINE__);
[secondVC release];
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
NSLog(@"接受内存告警");
// 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
//
// SecondViewController.m
// Ui03 - UIimageView
//
// Created by dllo on 15/11/10.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "SecondViewController.h"
@interface
SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.view.backgroundColor = [UIColor
greenColor];
UIButton *button = [UIButton
buttonWithType:UIButtonTypeCustom];
button.frame =
CGRectMake(150, 150, 150, 150);
button.backgroundColor = [UIColor
redColor];
[button addTarget:self
action:@selector(buttonAction)
forControlEvents:UIControlEventTouchDragInside];
[self.view
addSubview:button];
NSLog(@"bbb");
// Do any additional setup after loading the view.
}
- (void)buttonAction
{
//切回原来界面
//参数1 -
是否需要动画
//参数2 - block-
切换完成调用
//注意新建的rootVc的方式是切换到新的rootVC界面,而非切回原来的rootVC界面
[self
dismissViewControllerAnimated:YES
completion:^{
//NSLog(@"%d", __LINE__);
}];
// NSLog(@"%d", __LINE__);
}
- (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
//
// RootView.m
// Ui03 - UIimageView
//
// Created by dllo on 15/11/10.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "RootView.h"
@implementation RootView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
[self
createSubviews];
}
return
self;
}
- (void)createSubviews
{
//UIImage - 专门用来管理图片的类,本身不具备显示功能
//UIImageView-
专门用来显示图片的视图
//添加图片的2中方法
//1
// UIImage *image = [UIImage imageNamed:@"image4.jpg"];
// UIImageView *imagev = [[ UIImageView alloc]initWithImage:image];
// imagev.frame = self.view.frame;
// [self.view addSubview:imagev];
// [imagev release];
//2
常用
self.backgroundColor = [UIColor
whiteColor];
UIImageView *imagev = [[UIImageView
alloc]initWithFrame:CGRectMake(30, 30, 300,500)];
imagev.image = [UIImage
imageNamed:@"image9.jpg"];
[self addSubview:imagev];
[imagev release];
}
@end
相关文章推荐
- go build命令
- iOS UI 01 课堂笔记 -设计模式
- iOS UI 01 课堂笔记 -设计模式
- IOS UI 01 课堂笔记 -label
- IOS UI 01 课堂笔记 -label
- 使用yuicompressor-maven-plugin插件压缩JS和CSS静态资源
- UILabel: 如何可以更改除底部外的所有边框?
- Android 异步更新UI----handler+thread
- WebKit之CSSValue的继承关系
- JSP利用过滤器解决request中文乱码问题
- JavaSe String,StringBuffer,StringBuilder 简要区别(随记一)
- iOS环信3.0集成 (二)UI文件集成
- iOS多线程开发——NSOperation/NSOperationQueue浅析
- 使用Fluent API进行属性映射【Code-First系列】
- leetcode -- Permutation Sequence -- 重点
- APUE学习记录——进程环境
- Company BDui 面试 笔试 : 从10个已按从大到小排列好的数组中,求top 15个最大的数
- 62 You have enabled backup optimization in RMAN. You issue the following RMAN command to configure a
- HDU 1005:Number Sequence【规律】
- PyQt5系列教程(二)利用QtDesigner设计UI界面