2014-06-12 18 views
0

我開發的MacOSX的應用程序,我創建一個NSMatrix(單選按鈕)是這樣的:如何通過標籤在XCode5(可可)選擇編程NSMatrix無線電

arrayClasifCuentas = [[NSMutableArray alloc]init]; 
[arrayClasifCuentas addObject:@{@"tag": @"7",@"value": @"Seven"}]; 
[arrayClasifCuentas addObject:@{@"tag": @"8",@"value": @"Eight"}]; 
[arrayClasifCuentas addObject:@{@"tag": @"9",@"value": @"Nine"}]; 

NSButtonCell *prototype = [[NSButtonCell alloc] init]; 
[prototype setTitle:@"Radio"]; 
[prototype setButtonType:NSRadioButton]; 

NSRect matrixRect = NSMakeRect(20, 20, 125, 80); 

myMatrix = [[NSMatrix alloc] initWithFrame:matrixRect 
             mode:NSRadioModeMatrix 
           prototype:(NSCell *)prototype 
           numberOfRows:[arrayClasifCuentas count] 
          numberOfColumns:1]; 

NSArray *cellArray = [myMatrix cells]; 

for (int i = 0; i < [arrayClasifCuentas count]; i++) { 

    [[cellArray objectAtIndex:i] setTitle:[[arrayClasifCuentas objectAtIndex:i] objectForKey:@"value"]]; 
    [[cellArray objectAtIndex:i] setTag: [[[arrayClasifCuentas objectAtIndex:i] objectForKey:@"tag"]intValue ]]; 
} 

我要做的下一是以編程方式選擇選項七,但基於自己的標籤(7)如何做到這一點?

回答

1

試試這個

[myMatrix selectCell:[myMatrix cellWithTag:7]]; 
+0

你搖滾!完全作品謝謝! – Jesus