查看无法成为第一响应者
我有一个视图控制器。它是由另一个的 UINavigationController
推送的。 在 ViewController.m 中:
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)viewDidAppear:(BOOL)animated {
[self.view becomeFirstResponder];
NSLog(@"%d", [self.view isFirstResponder]);
[super viewDidAppear:animated];
}
它总是 0。为什么?
I have a view controller. It is pushed by another's UINavigationController
.
In ViewController.m:
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)viewDidAppear:(BOOL)animated {
[self.view becomeFirstResponder];
NSLog(@"%d", [self.view isFirstResponder]);
[super viewDidAppear:animated];
}
It's always 0. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的视图必须接受第一响应者状态。这是在您的视图子类代码中实现的,您必须重写
canBecomeFirstResponder
并返回YES:Your view has to accept first responder status. This is implemented in your view's subclass code, you have to override
canBecomeFirstResponder
and return YES: