iOS 用UIScrollView不能获取到touchesBegan
2013-08-23 20:58
211 查看
网上查了一下 原来UIScrollView是没有继承touchesBegan方法的 所以要自己重写UIScrollView 然后继承
touchesBegan 等方法才可以用
重写
UIScrollView很简单
代码下
.h
//
// myScrollView.h
// WFClient
//
// Created by 屎壳郎情调 on 13-8-23.
// Copyright (c) 2013年 ibokan. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface myScrollView :
UIScrollView
@end
.m
//
// myScrollView.m
// WFClient
//
// Created by 屎壳郎情调 on 13-8-23.
// Copyright (c) 2013年 ibokan. All rights reserved.
//
#import "myScrollView.h"
@implementation myScrollView
- (id)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
// Initialization code
}
return
self;
}
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super
touchesBegan:touches
withEvent:event];
//做你想要的操作
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[super
touchesEnded:touches
withEvent:event];
//做你想要的操作
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
使用的时候很简单 直接
//滚动视图
myScrollView *scrollView= [[myScrollView
alloc] initWithFrame:
CGRectMake( 0,
0, 320,
460)];
用法和UIScrollView 都是一样的
touchesBegan 等方法才可以用
重写
UIScrollView很简单
代码下
.h
//
// myScrollView.h
// WFClient
//
// Created by 屎壳郎情调 on 13-8-23.
// Copyright (c) 2013年 ibokan. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface myScrollView :
UIScrollView
@end
.m
//
// myScrollView.m
// WFClient
//
// Created by 屎壳郎情调 on 13-8-23.
// Copyright (c) 2013年 ibokan. All rights reserved.
//
#import "myScrollView.h"
@implementation myScrollView
- (id)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
// Initialization code
}
return
self;
}
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super
touchesBegan:touches
withEvent:event];
//做你想要的操作
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[super
touchesEnded:touches
withEvent:event];
//做你想要的操作
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
使用的时候很简单 直接
//滚动视图
myScrollView *scrollView= [[myScrollView
alloc] initWithFrame:
CGRectMake( 0,
0, 320,
460)];
用法和UIScrollView 都是一样的
相关文章推荐
- ios UIScrollView不能响应TouchesBegin:的事件的解决办法
- ios UIScrollView不能响应TouchesBegin:的事件的解决办法
- ios UIScrollView不能响应TouchesBegin:的事件的解决办法
- UIScrollView解决touchesBegan等方法不能触发的解方案
- IOS总结:UIScrollView不能滚动的几种可能性
- iOS UIScrollView不能响应touchBegin的解决方法
- ios UIScrollView不能响应TouchesBegin:的事件的解决办法
- ios开发 解决ios6中UIScrollView不能滚动的问题
- iOS软件开发之在UIScrollView上添加手势不能触发解决办法
- iOS UIScrollView的使用及其不能滑动问题解决
- 【IOS学习之常见问题】UIScrollView 不能滑动(ScrollView has ambiguous scrollable content height)
- iOS学习笔记---UIScrollView 常见属性 不能滚动 常见代理方法
- 第15月第6天 ios UIScrollView不能响应TouchesBegin
- AJ学IOS 之控制器view显示中view的父子关系及controller的父子关系_解决屏幕旋转不能传递事件问题
- iOS 视图:重绘与UIScrollView(内容根据iOS编程编写)
- IOS之UIScrollView的contentOffset介绍
- iOS利用UIScrollView实现图片的缩放实例代码
- iOS之UIScrollView固定UIScrollView滑动的方向
- ios通用上下刷新,适用UIView,UIScrollView...
- IOS学习2 IOS 使用NINetworkImageView下载图片,google地图图片的获取。