我正在尝试通过代码构建视图。在我的初始化中,我有这个:
- (id) init{
self = [super init];
if(self){
[self setFrame:CGRectMake(0, 0, 0, 50)];
[self addSubview:[self dateNumberView]];
NSDictionary *views = NSDictionaryOfVariableBindings(self.dateNumberView);
[self.dateNumberView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-[dateNumberView]-|" options:0 metrics:nil views:views]];
}
return self;
}
我得到的错误是:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: dateNumberView is not a key in the views dictionary. |-[dateNumberView]-|
怎么了?