0
已經建立了我的appDelegate以返回firstResponder狀態,但是當我編譯(它編譯好)時,控制檯返回「無法成爲第一響應者」,但沒有說明原因。不能返回firstResponder狀態
我附上了代碼。你能告訴我什麼是錯的嗎?提前致謝。
HypnosisterAppDelegate.m
#import "HypnosisterAppDelegate.h"
#import "HypnosisView.h"
@implementation HypnosisterAppDelegate
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
HypnosisView *view = [[HypnosisView alloc] initWithFrame:[[self window]bounds]];
[[self window]addSubview:view];
BOOL success = [view becomeFirstResponder];
if (success) {
NSLog(@"HypnosisView became the first responder");
} else {
NSLog(@"Could not become the first responder");
}
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
-(BOOL)canBecomeFirstResponder
{
return YES;
}
謝謝。我將canBecomeFirstResponder移動到HypnosisView,它工作! – pdenlinger 2012-04-28 17:56:00