UIViewController : UIResponder <NSCoding, UIAppearanceContainer, UITraitEnvironment, UIContentContainer>
关于UIViewController生命周期
loadView -> viewDidLoad -> viewWillAppear -> viewDidAppear -> viewWillDisappear -> viewDidDisappear
模态推出Modal
执行跳转
//模态推出Modal
//推出一个新的页面(viewController)
//1.创建新的页面
VisionSecondViewController *secondVC = [[VisionSecondViewController alloc]init];
//设置推出动画
[secondVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
//2. 推出
//参数1: 要推出的新视图控制器(viewController)
//参数2: 是不是带一个动画效果
//参数3:
[self presentViewController:secondVC animated:YES completion:^{
//推出新视图之后,要执行的代码
}];
//3.内存管理
[secondVC release];
跳转回执行目标
[self dismissViewControllerAnimated:YES completion:^{
//
}];
UIResponder : NSObject
UIImageView 和 UILable 默认关闭交互
需要打开 打开方法:
self.imageView.userInteractionEnabled = YES;
触摸事件
1.- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
2.- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
3.- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
4.- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
UITouch *touch = [touches anyObject];
摇晃事件
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);