當點擊背景的時候出發事件,或者跳轉界面或者產生其他的響應
-(void)viewDidLoad
{
UIImageView * imageView = [UIImageView alloc]initWithFrame:CGRectmake
(20,20,200,100)] ;
imageView.image = [UIImage imageName:@"aa.png"];
imageView.userInterationEnable = YES;
//主要的事應用這個類的方法
UITapGesturRecognizer * TapGesturRecognizer = [UITapGestureRecognizer alloc]
initWithTarget:self action:@selecter(tapGestureRecognizer);
[imageView addGestureRecognizer:TapGesturRecognizer ];
[self.view addSubview:imageView];
}
//點擊圖片時,釋放掉textfile的鍵盤
-(void)tapGestureRecognizer
{
[self.textfile resignFirstRsponder];