如何在viewDidLoad中的第一个收件人中创建NSTextView?

时间:2017-06-26 23:49:10

标签: objective-c macos nstextview

我使用"成为第一个响应者"在tv2,但任何文本输入到tv1。如何在此设置中将其设置为tv2。

- (void)viewDidLoad {
    [super viewDidLoad];

    tv1 = [[NSTextView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
    [self.view addSubview:tv1];
    tv1.string = @"dog";

    tv2 = [[NSTextView alloc] initWithFrame:CGRectMake(200, 0, 100, 50)];
    [self.view addSubview:tv2];
    tv2.string = @"cat";

    [tv2 becomeFirstResponder]; //fails to make this one take in keys strokes

0 个答案:

没有答案