【发布时间】:2010-10-28 11:40:52
【问题描述】:
我遵循了这个论坛上给出的一些建议,但我仍然遇到困难
我有以下:
#import <UIKit/UIKit.h>
@protocol UIViewForWheelProtocol
- (void) returnImageNumber:(int)imgNum;
@end
#import <UIKit/UIKit.h>
#import "UIViewForWheelProtocol.h";
@interface UIViewForWheel : UIView {
id<UIViewForWheelProtocol> delegate;
}
@property (nonatomic, assign) id<UIViewForWheelProtocol> delegate;
@implementation UIViewForWheel
@synthesize delegate;
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
int num =1 ;
[self.delegate returnImageNumber:num];
}
#import <UIKit/UIKit.h>
#import "UIViewForWheel.h"
#import "UIViewForWheelProtocol.h"
@interface MainMenu : UIViewController <UIViewForWheelProtocol> {
}
-(void) returnImageNumber:(int)whichImage;
@end
#import "MainMenu.h"
@implementation MainMenu
- (void) returnImageNumber:(int)whichImage
{
NSLog(@"HI %i", whichImage);
}
HI 1 没有被显示,因为虽然它会转到 touchesMoved 函数,但不会转到 MainMenu 类中的 returnImageNumber。
谁能解释一下我做错了什么?
【问题讨论】:
-
您是否曾将 MainMenu 实例指定为 UIViewForWheel 的委托?
-
我也没有看到
MainMenu的接口声明...那在哪里? -
@Marcelo,显然没有...请问我该怎么办?
-
好吧,您可以轻松编辑旧问题,而不是添加新问题...
标签: iphone objective-c delegates protocols