我知道這個問題似乎已經被問及答案,但我無法解決我的問題。TouchesMoved UIButton xcode 4.4 iOS 5.1.1
我想將我的觀點的對象跟隨手指的水平幻燈片(去上一頁或下一頁)
對於這一點,我使用的touchesBegan,TouchesMoved和TouchesEnded方法。
它在觸摸開始於視圖背景時正常工作,但在uibuttons觸摸開始時不起作用。
爲了解決這個問題,我已經子類,我想允許手勢的uibuttons,它工作正常,當我在Xcode的3.x和4.x版的iOS我剛裝了OSX頗富獅子
今天並開始使用xCode 4.4和iOS 5.1.1(iPAD)。 在這裏,我與同樣的應用程序,工作得很好,不再工作。
這裏是我的UIButton子類:
// myUIButton.h
#import <UIKit/UIKit.h>
@interface myUIButton : UIButton
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
@end
// myUIButton.m
#import "myUIButton.h"
@implementation myUIButton
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"uibutton touches began");
[self.nextResponder touchesBegan:touches withEvent:event];
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"uibutton touches moved");
[self.nextResponder touchesMoved:touches withEvent:event];
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"uibutton touches ended");
[self.nextResponder touchesEnded:touches withEvent:event];
}
@end
以下是我的主類中的方法:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"view touches began");
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"view touches moved");
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"view touches ended");
}
當我觸摸開始上的UIButton我從子類,但主要得到各的NSLog touchesMoved只執行一次。 (self.nextResponder似乎只能運行一次)
是否有任何更改,使其無法在xcode 4.4或iOS 5.1.1?
當我第一次嘗試這樣做(在Xcode的3.x和4.x版的iOS),我發現這裏的解決方案: Is there a way to pass touches through on the iPhone?
但它不工作了...
你能幫我?
非常感謝。
編輯:問題是使用相同的[超級倒是...]代替或更多的[self.nextResponder倒是...]
你解決了嗎?我面臨着類似的問題。我有Fingerpaint,它可以在iOS 6上正常工作,但在我的新iPad iOS7上,它不會呈現,直到touchesEnded。 touchesBegan之後只繪製了一小部分。 – 2013-11-16 21:00:15
很抱歉回答遲到,但郵件已經發送到垃圾郵件箱。 我確實解決了我的問題,但不記得我是如何編寫我認爲正確的答案的。 – 2014-01-16 15:18:40