How can I call protocol?
Here is a code that I based on "ScrollViewSuite".
I can get "Test", but I cannot get "Test5".
Please advice what I am missing.
Regards,
Here is a code that I based on "ScrollViewSuite".
Code:
@protocol TestViewTouchDelegate;
@interface TestView : TestGLView
{
// Interaction.
id <TestViewTouchDelegate> touchDelegate;
}
// Interaction.
@property(nonatomic, assign) id <TestViewTouchDelegate> touchDelegate;
@end
@protocol TestViewTouchDelegate <NSObject>
@optional
- (void)tapDetectingView:(UIView *)view touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event;
@end
Code:
#import "TestView.h"
@implementation TestView
@synthesize touchDelegate;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[touchDelegate tapDetectingView:self touchesBegan:touches withEvent:event];
// update our touch state
if ([[event touchesForView:self] count] > 1)
multipleTouches = YES;
if ([[event touchesForView:self] count] > 2)
twoFingerTapIsPossible = NO;
NSLog(@"Test");
}
Code:
#import "TestView.h"
@interface TestObject : NSObject <TestViewTouchDelegate> {
// Interaction.
id <TestViewTouchDelegate> touchDelegate;
float gDrawRotateAngle;
}
// Interaction.
@property(nonatomic, assign) id <testViewTouchDelegate> touchDelegate;
@end
Code:
#import "TestView.h"
@implementation TestObject
@synthesize touchDelegate;
- (void)updateWithTimeDelta:(NSTimeInterval)timeDelta
{
gDrawRotateAngle += (float)timeDelta * 45.0f; // Rotate cube at 45 degrees per second.
if (gDrawRotateAngle > 360.0f) gDrawRotateAngle -= 360.0f;
}
- (void)tapDetectingView:(UIView*)view touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
gDrawRotateAngle = !gDrawRotateAngle;
NSLog(@"Test5");
}
I can get "Test", but I cannot get "Test5".
Please advice what I am missing.
Regards,