Ios 给imageview 添加手势没有反应
道理差不多,简单写写,就是给UIImage所在的UIImageView添加个单击的手势,让用户点击图片时有响应的响应。
- (void)viewDidLoad
{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap =
[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(whenClickImage)];
[imageView addGestureRecognizer:singleTap];
[imageView setImage:[UIImage imageNamed:@"1.png"]];
[singleTap release];
[self.view addSubview: imageView];
}
-(void)whenClickImage
{
NSLog(@"you click image");
}
不仅UIImageView可以添加,UIScrollView上也可以。还可以添加其他双击旋转等手势。
比较简单实用。
原文地址:http://blog.sina.com.cn/s/blog_6f453dd601016idd.html
Ios 给imageview 添加手势没有反应的更多相关文章
- 李洪强iOS开发之添加手势
李洪强iOS开发之添加手势 02 - 添加手势
- iOS 给imageview添加模糊度
开发工具带的swift2.3,3.0的朋友们改改语法吧! 首先要有一个UIimageview然后: 我是声明了一个全局的UIVisualEffectView------- private var ef ...
- iOS开发——给ImageView添加点击事件
给ImageView添加点击事件 1: cell.pictureView.userInteractionEnabled = YES; 2: UITapGestureRecognizer ...
- IOS的七种手势
今天为大家介绍一下IOS 的七种手势,手势在开发中经常用到,所以就简单 通俗易懂的说下, 话不多说,直接看代码: // 初始化一个UIimageView UIImageView *imageView ...
- iOS之触摸及手势
触摸事件 iOS中的事件: 在用户使用app过程中,会产生各种各样的事件.iOS中的事件可以分为3大类型: view的触摸事件处理: 响应者对象: 在iOS中不是任何对象都能处理事件,只有继承了 ...
- IOS 进度条与手势
//进度条#import "ViewController.h" @interface ViewController () { UIImageView* _animaImageV; ...
- iOS事件处理之七种手势
手势在开发中经常用到,所以就简单通俗易懂的说下, 话不多说,直接看代码: // 初始化一个UIimageView UIImageView *imageView = [[UIImageView allo ...
- IOS 为UILabel添加长按复制功能
IOS 为UILabel添加长按复制功能 在iOS中下面三个控件,自身就有复制-粘贴的功能: 1.UITextView 2.UITextField 3.UIWebView UIKit framewor ...
- iOS开发 解决UITapGestureRecognizer手势与UITableView的点击事件的冲突
该篇文章摘自我的新浪博客,原文地址为: http://blog.sina.com.cn/s/blog_dcc636350102wavx.html UITableView 拥有属于自己的点击事件,在将一 ...
随机推荐
- 使用 Windows PowerShell 管理Windows Azure映像
你可以使用 Azure PowerShell 模块中的 cmdlet 管理可供你的 Azure 订阅使用的映像.这包括 Azure 提供的映像以及你上载的映像.对于某些映像任务,你还可以使用 Azur ...
- Learning JavaScript Design Patterns The Singleton Pattern
The Singleton Pattern The Singleton pattern is thus known because it restricts instantiation of a cl ...
- 一切皆WEB
所有应用都应该成为Web应用吗?当然不是.总有一些重要的例外,有些种类的软件跟网络也毫无关系.但是,这些是少数情况,是一些特殊应用.它们固然是重要的小生态环境,但不管怎么说,就只是“小生态”. 如果你 ...
- Symfony VarDumper Component
Symfony VarDumper 类似 php var_dump() 官方文档写的安装方法 : 按照步骤 就可以在 running any PHP code 时候使用了 In order to h ...
- Yii2 TimestampBehavior行为
<?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * ...
- HttpClientUtil
package com.uniubi.management.util; import java.io.IOException; import java.io.InterruptedIOExceptio ...
- Android---用Wi-Fi来建立对等连接
本文译自:http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html WiFi对等API(P2P ...
- 【C语言】编写一个函数实现n^k,使用递归实现
#include <stdio.h> int fuc(int x,int n) { if(n!=1) return x*fuc(x,n-1); return 1; } int main() ...
- [HTTP] Origins, CROS, Preflight
Origins made up of three parts the data scheme, the hostname and the prot. It is important to know t ...
- 认识CoreData-使用进阶
之前两篇文章都比较偏理论,文字表达比较多一些,但都是干货!学习时先理解理论知识,才能更好的帮助后面的理解. 在这篇文章中,将会涉及关于CoreData的一些复杂操作,这些操作会涉及分页查询.模糊查 ...