【发布时间】:2016-11-11 11:08:36
【问题描述】:
imageView 被正确绑定为 IBOutlet ("imageOKData")。我以编程方式将其可见性(隐藏)绑定到创建绑定时已经可用的自定义对象的 BOOL 属性。
在ViewController.m:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Create binding: %hhd",_global.dataFile.imported);
// --> "Create binding: 0"
NSDictionary* reverseBool = [NSDictionary dictionaryWithObjectsAndKeys:NSValueTransformerNameBindingOption,NSNegateBooleanTransformerName,
nil];
[_imageOKData bind:@"hidden" toObject:_global.dataFile withKeyPath:@"imported" options:reverseBool];
}
使用上面的代码,图像应该在viewDidLoad 之后隐藏。但它仍然可见。即使我删除了reverseBool 选项,它仍然存在。我做错了什么?
【问题讨论】:
标签: objective-c binding