0

I have a little application with two views. What I don't understand is that I can't seemed to manage how I can manually assign the first responder status to a particular view.

I have this code in awakeFromNib method.

-(void)awakeFromNib{
NSView *a = [[firstView alloc]init];
NSView *b = [[secondVIew alloc]init];

[b becomeFirstResponder];
[a resignFirstResponder];

}

Why is this not working?

4

1 回答 1

0

首先,我会在成为第一响应者之前先辞职。

要获得更详细的答案,我们需要了解与视图控制器相关的视图布局。通常,您在视图控制器中分配 firstResponder。由于您正在覆盖 awakeFromNib,因此很明显该代码段不在 viewController 中。

最后,不要忘记调用 super。

于 2013-06-24T20:03:00.713 回答