我有一个NSSegmentedControl,在Interface Builder中将两个段设置为“Select None”模式。无论我尝试什么,我都无法使-selectedSegment返回除0之外的任何内容,即使段0默认为禁用状态,也不可能被选中。下面是当你点击控件中的任何段被调用相关功能:NSSegmentedControl -selectedSegment总是返回0
-(IBAction)changeStep:(id)sender
{
[stepContainer setHidden:TRUE];
[(NSView *)[[wizard stepArray] objectAtIndex:(NSInteger)[wizard step]] removeFromSuperview];
switch ([[navigationButton cell] selectedSegment])
{
case 0:
[wizard setStep:(NSInteger *)[wizard step]-1];
break;
case 1:
[wizard setStep:(NSInteger *)[wizard step]+1];
break;
default:
break;
}
//[[navigationButton cell] setSelected:FALSE forSegment:[navigationButton selectedSegment]];
if ([wizard step] > 0)
{
[wizard setStep:0];
[navigationButton setEnabled:FALSE forSegment:0];
}
NSLog(@"%d", [wizard step]);
[stepContainer addSubview:(NSView *)[[wizard stepArray] objectAtIndex:(NSInteger)[wizard step]]];
[stepContainer setHidden:FALSE withFade:TRUE];
}
我使用-isSelectedForSegment也尝试过,但它有同样的结果。
你可以提供的任何帮助将是非常棒的,我不知道我做错了什么。谢谢!
SphereCat1
编辑:这是一个facepalm时刻,请参阅下面的答案。
它确实是initalized。 NSLog返回 –
vilhalmer
2010-05-17 01:01:10