简体   繁体   中英

How to deselect radio button in cocoa

I'm a newbie. I have a problem with NSMatrix. I created mutiple NSMatrix but i want first loading, they not checked. I used this code to created them but it always checked.

 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];

Any ideas? Thanks a lot

在NSButtonCell上,您将使用NSCellsetState方法:

[prototype setState:NSOffState]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM