UIEvent

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:@"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值