UIEvent:事件,是由硬件捕捉的一个表示永和操作设备的对象。
分为三类:触摸事件,晃动事件、远程控制事件
触摸事件:用户通过触摸设备屏幕操作对象、输入数据。支持多点触摸,包含1个到多个触摸点。
// RootViewController.m
#import "RootViewController.h"
#import "ChangeLocationView.h"
#import "SecondViewController.h"
@interfaceRootViewController ()
@end
@implementationRootViewController
- (void)viewDidLoad {
[superviewDidLoad];
// 事件: 由硬件捕捉到用户对设备的一个操作
// 事件: 触摸事件,摇晃事件,远程控制事件
ChangeLocationView *changeView =[[ChangeLocationViewalloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
changeView.backgroundColor =[UIColorredColor];
[self.viewaddSubview:changeView];
UIButton *button =[UIButtonbuttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(100, 400, 50,50);
button.backgroundColor =[UIColorblueColor];
[buttonaddTarget:self action:@selector(touch)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:button];
[changeView release];
}
- (void)touch{
SecondViewController *secondVC =[[SecondViewControlleralloc]init];
// 跳转
[selfpresentViewController:secondVCanimated:YES completion:^{
}];
[secondVC release];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// SecondViewController.m
#import "SecondViewController.h"
#import "MyView.h"
#import "ThirdViewController.h"
@interfaceSecondViewController ()
@property (nonatomic,retain)MyView *myView;
// 计数器用来记录摇晃的次数
@property (nonatomic,assign)NSIntegercount;
@end
@implementationSecondViewController
- (void)dealloc{
[_myView release];
[superdealloc];
}
- (void)viewDidLoad {
[superviewDidLoad];
self.view.backgroundColor =[UIColorbrownColor];
self.myView =[[MyViewalloc]initWithFrame:[UIScreenmainScreen].bounds text:@"