当前位置:编程学习 > wap >>

iOS给背景添加点击事件

当点击背景的时候出发事件,或者跳转界面或者产生其他的响应

-(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];

 


 

补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,