ios学习记录 day27 UI 5 事件处理

事件概述

UIEvent:事件,是由硬件捕捉的一个表示用户操作设备的对象

分三类:触摸 晃动 远程控制

触摸事件:会包含一个到多个UITouch        Began Move End

UITouch概述

UIView支持触摸 ,而且支持多点(UIView继承UIResponder)

需要定义UIView子类,实现触摸相关方法  实现touches...began  touches...move  touches...end  touches...cancelled方法(记录手指坐标)

                                                     当触摸序列被诸如电话呼入这样的系统事件所取消时,发送touchesCancelled:withEvent:消息。

重写drawRect:

 

添加撤销按钮

 

 

对数组字典的复习

.h

@property (nonatomic, retain) NSMutableArray *bigArray;

 

//    NSArray * arr = [NSArray arrayWithObjects:@"aa",@"bb",@"cc",@"dd",@"ee", nil];
//    
//    NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys:@"object",@"key",@"object1",@"key1", nil];
//    NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:arr,@"arr", nil];
//    
//    NSArray * dicObjects = [NSArray arrayWithObjects:arr, nil];
//    NSArray * names = [NSArray arrayWithObjects:@"arr", nil];
//    NSDictionary *dic2 = [NSDictionary dictionaryWithObjects:dicObjects forKeys:names];
//    NSArray *a = [dic2 objectForKey:@"arr"];
//    NSLog(@"a == %@",a);
    
    self.bigArray = [NSMutableArray array];
    NSLog(@"big array1 == %@",_bigArray);
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    NSLog(@"dic == %@",dic);
    
    [dic setObject:[UIColor redColor] forKey:@"color"];
    NSLog(@"%@",dic);
    
    NSMutableArray * arr = [NSMutableArray array];
    [arr addObject:@"+"];
    
    [dic setObject:arr forKey:@"array"];
    NSLog(@"dic == %@",dic);
    
    [_bigArray addObject:dic];
    NSLog(@"bigArray2 == %@",_bigArray);
    [self insertIntoDic];
}

- (void)insertIntoDic//向字典中添加内容
{
    for (NSMutableDictionary *dic in _bigArray) {
        NSMutableArray * array = [dic objectForKey:@"array"];
        [array addObject:@"hello"];
        NSLog(@"bigArray3 == %@",_bigArray);
    }
}

 

posted @ 2014-04-08 20:15  lxl奋小斗  阅读(141)  评论(0编辑  收藏  举报