我有一个视图控制器。它由另一个UINavigationController
推动。
在ViewController.m中:
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)viewDidAppear:(BOOL)animated {
[self.view becomeFirstResponder];
NSLog(@"%d", [self.view isFirstResponder]);
[super viewDidAppear:animated];
}
总是0.为什么?
答案 0 :(得分:6)
您的观点必须接受第一响应者状态。这是在您的视图的子类代码中实现的,您必须覆盖canBecomeFirstResponder
并返回YES:
- (BOOL)canBecomeFirstResponder
{
return YES;
}