iOS UI 02 UIimageview 和模态切换
来源:互联网 发布:ubuntu语言设置成中文 编辑:程序博客网 时间:2024/05/12 06:10
注意这是哪一个文件!!!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 {
[superviewDidLoad];
self.view.backgroundColor = [UIColorwhiteColor];
RootView *rootV = [[RootViewalloc]initWithFrame:[[UIScreenmainScreen] bounds] ];
[self.viewaddSubview:rootV];
[rootV release];
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(150, 150, 150, 150);
button.backgroundColor = [UIColorredColor];
[button addTarget:selfaction:@selector(buttonAction)forControlEvents:UIControlEventTouchDragInside];
[self.viewaddSubview: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 = [[SecondViewControlleralloc]init];
//切换页面
//参数1,要切换的界面
//参数2,是否需要动画特效
//参数3 , block -
[selfpresentViewController:secondVC animated:YEScompletion:^{
//切换完成调用
// NSLog(@"%d", __LINE__);
}];
//presentViewController会引起引用计数增加
// NSLog(@"%ld", secondVC.retainCount);
//先执行完成此方法(buttonAction),再去切换界面
// NSLog(@"%d", __LINE__);
[secondVC release];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
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 {
[superviewDidLoad];
self.view.backgroundColor = [UIColorgreenColor];
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(150, 150, 150, 150);
button.backgroundColor = [UIColorredColor];
[button addTarget:selfaction:@selector(buttonAction)forControlEvents:UIControlEventTouchDragInside];
[self.viewaddSubview:button];
NSLog(@"bbb");
// Do any additional setup after loading the view.
}
- (void)buttonAction
{
//切回原来界面
//参数1 -是否需要动画
//参数2 - block-切换完成调用
//注意新建的rootVc的方式是切换到新的rootVC界面,而非切回原来的rootVC界面
[selfdismissViewControllerAnimated:YEScompletion:^{
//NSLog(@"%d", __LINE__);
}];
// NSLog(@"%d", __LINE__);
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// 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 = [superinitWithFrame:frame];
if (self) {
[selfcreateSubviews];
}
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 = [UIColorwhiteColor];
UIImageView *imagev = [[UIImageViewalloc]initWithFrame:CGRectMake(30, 30, 300,500)];
imagev.image = [UIImageimageNamed:@"image9.jpg"];
[self addSubview:imagev];
[imagev release];
}
@end
- iOS UI 02 UIimageview 和模态切换
- IOS UI控件 - UIImageView
- IOS UI 手写 UIImageView
- iOS中ui单列模式 uibutton和uiimageview 的区别
- IOS(UI)_UIButton(按钮)和UIImageView(图片按钮)
- IOS(UI)_UIButton(按钮)和UIImageView(图片视图)
- IOS--UI--LessonUIControl UIImageView/ UISegmentedControl
- iOS -UI-06 UIImageView 动画
- UI - UIImageView 和页面跳转
- UI之UILabel和UIImageView
- IOS模态视图 (UI页面切换)
- iOS:UIimageView切换图片渐入渐出的动画
- iOS:UIimageView切换图片渐入渐出的动画
- iOS UI篇 学习笔记 UIButton,UIImageView
- [IOS]今天开始学UI---UIImageView
- iOS之UI随笔-UIButton与UIImageView
- iOS系列UI篇——UIImageView
- iOS UI基础控件之UIImageView
- React Native环境配置
- 归并两个有序链表
- mac下配置eclipse的安卓开发环境
- 单精度float和双精度double
- poj 3565 Ants KM算法
- iOS UI 02 UIimageview 和模态切换
- Android Support Library包使用的问题
- 三维旋转:旋转矩阵,欧拉角,四元数
- 使用boost::property_tree解析xml与json (一):概述
- 欢迎使用CSDN-markdown编辑器
- C++函数传递参数的方式
- 使用boost::property_tree解析xml与json (二):parse_xml设计
- 基于ASP.NET的Comet长连接技术解析
- mysql sql_mode 使用