触摸:
“`
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
UIButton* btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(30, 50, 60, 30);
btn.backgroundColor = [UIColor grayColor];
[btn setTitle:@"上一页" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
for (NSInteger i = 0; i < 3; i++) {
UILabel* Txt = [[UILabel alloc]initWithFrame:CGRectMake(30, 100+50*i, 260, 30)];
Txt.backgroundColor = [UIColor grayColor];
Txt.textAlignment = NSTextAlignmentCenter;
Txt.tag = 10+i;
[self.view addSubview:Txt];
}
self.view.multipleTouchEnabled = YES;
}
-(void)btnAction:(UIButton*)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
//以下的方法是UIResponder的方法,不管是视图还是视图控制器都可以实现这一组方法,因为他们都是继承自UIResponder类
//触摸开始会调用此方法
-(void)touchesBegan:(NSSet