网上查了一下 原来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
//
// 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 都是一样的
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:http://bianchenghao.cn/39293.html