显示  view -》层  W T N V

交互 1.接收事件 2。响应事件

view

---------------------------------------------

modle arr dic熟练

处理数据

---------------------

controller

1.控制m。v

响应事件的方法 在此用



接收事件  

1.touch事件 (触摸事件)

2.Motion事件 (摇晃事件)

3.Remote事件 (远程事件)蓝牙耳机 下面栏音乐的快进慢放等

只有UIResponder这个类有这个接收事件的能力


响应者链 中实现


从WINDOW开始

w判断 1上面有无子视图 rootvc subview 有哪个传哪个 都有先subview 后rootvc

window rootvc rootview

touchBegin判断window能否响应事件

判断2 没有则检测该层能否响应事件

不能就穿回去



传递到不能传递 在响应

看m里 有没有touchbegin方法

有就是能响应

uicontroller有例外




UIGestureRecongnizer回去看看

UIButton *button = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];

   button.frame = CGRectMake(100, 100, 100, 100) ;

   [button addTarget:selfaction:@selector(tapButton) forControlEvents:UIControlEventTouchUpInside];

   [self.viewaddSubview:button];


UIView *aview = [[UIViewalloc]initWithFrame:CGRectMake(20, 20, 50, 50)];

   aview.backgroundColor = [UIColoryellowColor];

   aview.userInteractionEnabled = YES;

   [button addSubview: aview];


//双击生效

UITapGestureRecognizer *tap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tapButton)];

   tap.numberOfTapsRequired  =2;

   [aview addGestureRecognizer:tap];




---------------------------------------------------------------------------------------


委托模式