标签:屏幕触摸事件 摇一摇晃动时间 模拟摇一摇 模拟内存管理
1.建立根视图控制器
原代码:
// 设置根视图控制器
MainViewController *mainVC=[[MainViewController alloc] init];
_window.rootViewController =mainVC;
[mainVC release];
原代码:
1.-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"触摸开始");
}
2.-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"触摸结束");
}
3.-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"触摸被取消");
}
4.-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"触摸移动");
}
// 摇一摇
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
NSLog(@"摇一摇开始");
self.view.backgroundColor =[UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:0.5];
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
NSLog(@"摇一摇结束");
}
-(void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event{
NSLog(@"摇一摇被取消");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
NSLog(@"内存警告");
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:屏幕触摸事件 摇一摇晃动时间 模拟摇一摇 模拟内存管理
原文地址:http://blog.csdn.net/mltianya/article/details/47261193