[英]NSSwitchCell doesn't change value after clicking it
我已經將NSSwitchCells列綁定到NSArrayController。 值ON / OFF正確顯示,但是當我單擊它時,該值不會更改。 開關框提供了單擊的視覺反饋,但該值保持不變(選中或未選中)。
我嘗試了各種綁定選項。
NSDictionary *bindingOptions = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:1], NSContinuouslyUpdatesValueBindingOption,
[NSNumber numberWithInteger:1], NSRaisesForNotApplicableKeysBindingOption,
[NSNumber numberWithInteger:1], NSConditionallySetsEditableBindingOption,
[NSNumber numberWithInteger:1], NSValidatesImmediatelyBindingOption,
nil];
[tableColumn bind:@"value" toObject:currentItemsArrayController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", editedColumnmetadata.columnBindingKeyPath] options:bindingOptions];
[(NSButtonCell*)cell setButtonType:NSSwitchButton];
[cell setTitle:@""];
[tableColumn setDataCell:cell];
謝謝
更新:(綁定到單元格?)
//[tableColumn bind:@"value" toObject:currentItemsArrayController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", editedColumnmetadata.columnBindingKeyPath] options:bindingOptions];
[cell bind:@"objectValue" toObject:currentItemsArrayController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", editedColumnmetadata.columnBindingKeyPath] options:bindingOptions];
您必須按照以下步驟操作,如果您需要更多詳細信息,請告訴我:-
首先,您必須將復選框單元格的列綁定到綁定檢查器內部的arraycontroller,如下面的屏幕快照所示。
如果要更新復選框單元格的值,請在數組控制器中進行第二件事,然后編寫以下操作方法,然后將此操作方法僅連接到復選框單元格的表列。
-(IBAction)clickChekBoxcell:(id)sender
{
NSInteger chkCell=[sender integerValue];
NSNumber *num=[NSNumber numberWithInteger:chkCell];
NSMutableDictionary *dict=[NSMutableDictionary dictionary];
for(dict in [arrCont arrangedObjects])
{
[dict setObject:num forKey:@"checkYesNo"];
}
[arrCont rearrangeObjects];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.