【问题标题】:NSLevelIndicator: detect click and updateNSLevelIndicator:检测点击并更新
【发布时间】:2013-03-19 23:17:17
【问题描述】:

我想使用NSLevelIndicator 来管理我的应用程序中的评级,但我不明白如何检测点击它并更新评级。

这是代码:rate 属性是在 .h 文件中创建的,它是在 IB 中正确链接的 IBOutlet。

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

    NSLevelIndicatorCell *cell = [[NSLevelIndicatorCell alloc] initWithLevelIndicatorStyle:NSRatingLevelIndicatorStyle];

    [cell setMinValue:0.0];
    [cell setMaxValue:5.0];

    [cell setFloatValue:3.0];

    [cell setTarget:self];

    [cell setAction:@selector(click:)];

    [self.rate setCell:cell];


}

- (IBAction)click:(id)sender
{

    //How to detect change in rating here???

}

【问题讨论】:

    标签: objective-c nslevelindicator


    【解决方案1】:

    我为其他有相同“问题”的人发布解决方案。

    用户交互对我不起作用的原因是因为我需要致电[cell setEnabled:YES]。 可能这个属性默认设置为NO

    【讨论】:

      【解决方案2】:

      也许这是一个错误,但 setEnabled: 并不能解决任何问题,而 setEditable: 可以。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-16
        • 2015-01-22
        • 2020-04-18
        相关资源
        最近更新 更多