在Cocos2d中的UITextField示例中,根据最受欢迎的答案,我已经成功实现了它,但是遗漏了这一行。
[[[UIApplication sharedApplication] delegate] specifyStartLevel];
我将它放在我的场景中,然后收到了这个警告:
实例方法'-specifyStartLevel'未找到(返回类型默认为'id')
为什么会这样?我明明在我的AppDelegate的头文件和实现文件中定义了-specifyStartLevel
...
编辑:声明specifyStartLevel
#import <UIKit/UIKit.h>
@class RootViewController;
@interface AppDelegate : NSObject <UIApplicationDelegate,UITextFieldDelegate> {
UIWindow *window;
UITextField *levelEntryTextField;
RootViewController *viewController;
}
- (void)specifyStartLevel;
@property (nonatomic, retain) UIWindow *window;
@end
实现:
- (void)specifyStartLevel
{
[levelEntryTextField setText:@""];
[window addSubview:levelEntryTextField];
[levelEntryTextField becomeFirstResponder];
}