[iOS Dev] UIScrollView的touchesBegan和touchesEnd
touchesBegan跟touchedEnd沒有提供給UIScrollViewDelegate
所以要自己建立一個繼承自UIScrollView的class
重寫這兩個method
▼ myScrollView.h
1
2
|
@interface myScrollView : UIScrollView @end |
▼ myScrollView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
-( void ) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
if ( !self.dragging )
{
[[self nextResponder] touchesBegan:touches withEvent:event];
}
} -( void ) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesEnded:touches withEvent:event];
if ( !self.dragging )
{
[[self nextResponder] touchesEnded:touches withEvent:event];
}
} |
之後建立UIScrollView就是用myScrollView建立 即可使用這兩個method
1
|
myScrollView *contentScrollView = [[myScrollView alloc] init]; |
相关推荐
UIScrollView不能响应UITouch事件的解决办法,原因是:UIView的touch事件被UIScrollView捕获了。 解决办法:让UIScrollView将事件传递过去。于是最简单的解决办法就是加一个UIScrollView的category。这样每个用到...
UIScrollView、UIScrollView基本用法、UIScrollView详解,UIScrollView常用方法
定时滚动和循环滚动,可点击图片和PageController #import "ASIFormDataRequest.h" #import "GWPublicClass.h" @interface ViewController () @end @implementation ViewController { UIScrollView * ...
iOS:UIScrollView实现轮播,UIScrollView实现轮播,UIScrollView实现轮播
用UIScrollView 创建的轮播图,包含UIPageControl UIScrollView NSTimer
UIScrollView 用法详解UIScrollView 用法详解
UIScrollView实现自动轮播,可调节图片张数,轮播时间。
自定义view,实现UIScrollView自动滚动和手动滚动的结合
UIScrollView分页循环滑动,UITableView横向滑动
UIScrollview 循环滚动 手势 NSTimer
UIScrollView 无限自动循环 类似商品推荐产品图无限循环,配合UIPageControl使用
UIScrollView 原理 iOS开发
UIScrollView 无限循环
UIScrollView代理触摸实现_图片缩放UIScrollView代理触摸实现_图片缩放
此Demo是在故事板中的UIScrollView使用AutoLayout实现滚动
UIScrollView Demo 滚动视图 UIImageVIew 代码
一种N个UIScrollView嵌套的解决方案 使用了一种UIKit Dynamic + Gesture来处理多个UIScrollView、UITableView互相嵌套冲突的解决方案
UIScrollView图片定时滚动和点击
UNITY NGUI UIScrollView Demo 写的一个小Demo
UIScrollView和UIScrollView使用的例子