gpt4 book ai didi

iphone - 当我将触摸事件传递给 super View 时,MyScrollView 不响应触摸

转载 作者:行者123 更新时间:2023-12-03 20:16:26 25 4
gpt4 key购买 nike

我有一个带有 ScrollView SubView 的 ViewController,这些 subview 中有一个 subview ,下面是层次结构:

AppDelegate - MyViewController - ScrollView(来自xib) - MyScrollViewSubClass

//MyViewController ://.h

@interface MyViewController : UIViewController<MyScrollViewSubClassDelegate,UIScrollViewDelegate> {
UIScrollView *scrollView; // Loaded from xib
}

@property(nonatomic,retain) IBOutlet UIScrollView *scrollView;

@end

//.m

@implementation MyViewController

@synthesize scrollView;

- (void)viewDidLoad {
[super viewDidLoad];

scrollView.delegate = self;

MyScrollViewSubClass *myScrollView = [[MapScrollView alloc] init];
myScrollView.delegate = self;
myScrollView.myDelegate = self;

scrollView addSubview:mapScrollView];
}

// The MyScrollViewSubClassDelegate @required method

- (void) onDoubleTapLocation: (CGPoint)tapPoint
{
// Working,,,NSLog shown that this line is Working...
}

//MyScrollViewSubClass + 委托(delegate)//.h

// Protocol
@protocol MyScrollViewSubClasswDelegate <NSObject>
@required
- (void) onDoubleTapLocation: (CGPoint)tapPoint;
@end

//Interface

@protocol MyScrollViewSubClass;

@interface MyScrollViewSubClass : UIScrollView <UIScrollViewDelegate> {
id <MyScrollViewSubClasswDelegate> myDelegate;

// Another vars..
}

@property (nonatomic,assign) id<MyScrollViewSubClasswDelegate> myDelegate;

- (void)handleDoubleTap;

@end

//.m

@implementation MyScrollViewSubClass
@synthesize myDelegate;

- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {

// Another Code Here...

self.delegate = self; // delegate for UIScrollView
self.myDelegate = self;

//Another Code Here...

}
return self;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if(isDoubleTap)
{
//Call handle double tap
[self handleDoubleTap];
}
}

- (void)handleDoubleTap {
[self.myDelegate onDoubleTapLocation: tapLocation];
}

发生的事情是双击在 MyViewController 上工作,但现在我无法从 MyViewController 滚动和捏缩放我的 MyScrollViewSubClass,欢迎任何批评、评论或更好的方法..

已解决:

我在MyViewController上分配委托(delegate)两次

是:

myScrollView.delegate = self;
myScrollView.myDelegate = self;

应该是:

myScrollView.myDelegate = self;

问候,

渡轮哈塔维迪安

最佳答案

已解决:

我在 MyViewController 上分配委托(delegate)两次

是:

myScrollView.delegate = self; 
myScrollView.myDelegate = self;

应该是:

myScrollView.myDelegate = self; 

其他一切都运行良好...谢谢大家...

关于iphone - 当我将触摸事件传递给 super View 时,MyScrollView 不响应触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4420290/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com