如何在可可中取消选择单选按钮

时间:2013-08-08 07:33:41

标签: objective-c macos cocoa nsmatrix

我是新手。我有NSMatrix的问题。 我创建了多个NSMatrix,但我想首先加载,他们没有检查。 我用这段代码创建了它们,但总是检查它。

 prototype= [[NSButtonCell alloc] init];
    [prototype setTitle:@""];
    [prototype setButtonType:NSRadioButton];
    NSRect matrixRect = NSMakeRect(400, textfield_Y, 50, 20);
    myMatrix = [[NSMatrix alloc] initWithFrame:matrixRect
                                          mode:NSRadioModeMatrix
                                     prototype:(NSCell *)prototype
                                  numberOfRows:1
                               numberOfColumns:1];
    [myMatrix setTag:300+i];
    //[myMatrix setAction:@selector(radioButtonClicked:)];
    [myMatrix setTarget:self];
    NSArray *cellArray = [myMatrix cells];
    [[cellArray objectAtIndex:0] setTag:0];
    [guiView addSubview:myMatrix];
    [prototype release];
    [myMatrix release];

有什么想法吗?非常感谢

1 个答案:

答案 0 :(得分:1)

在NSButtonCell上,您将使用setState的{​​{1}}方法:

NSCell