首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSRuleEditor:新行的条件

NSRuleEditor:新行的条件
EN

Stack Overflow用户
提问于 2009-12-19 22:04:23
回答 1查看 853关注 0票数 5

当我在NSRuleEditor中点击一行上的"+“按钮时,就会创建一个新行。我如何影响用于该行的标准。

NSRuleEditor似乎默认从可能的值列表中按顺序选择第一个标准。我更希望新行与单击"+“的行相匹配。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-12-23 19:03:18

我可以通过子类化一个私有方法来伪造它:

代码语言:javascript
复制
- (void)_addOptionFromSlice:(id)slice ofRowType:(unsigned int)type
{
    int rowIndex = [(NSRuleEditorViewSlice*)slice rowIndex];

    NSArray *criteriaForRow = [self criteriaForRow:rowIndex];
    NSArray *displayValuesForRow = [self displayValuesForRow:rowIndex];

    self.template = [NSArray arrayWithObjects:criteriaForRow, displayValuesForRow, nil];

    [super _addOptionFromSlice:slice ofRowType:type];
}

- (void)insertRowAtIndex:(NSInteger)rowIndex withType:(NSRuleEditorRowType)rowType asSubrowOfRow:(NSInteger)parentRow animate:(BOOL)shouldAnimate
{
    [super insertRowAtIndex:rowIndex withType:rowType asSubrowOfRow:parentRow animate:shouldAnimate];

    NSArray *template = self.template;

    if (template != nil) {
        [self setCriteria:[template objectAtIndex:0] andDisplayValues:[template objectAtIndex:1] forRowAtIndex:rowIndex];
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1932991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档