Trying my hand at the visual format language for iOS but I'm getting a sigabrt when trying to initialize the constraints. Any glaring issues with this code?

    NSNumber *inset = [NSNumber numberWithFloat:TopBarInsetWidth];
    NSNumber *width = [NSNumber  numberWithFloat:TopBarButtonWidth];
    NSNumber *height = [NSNumber numberWithFloat:TopBarButtonHeight];
    NSDictionary *metrics = NSDictionaryOfVariableBindings(inset,width,height);
    NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(self.backButton);
    NSArray *constraints =[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-inset-[self.backButton(=width)]|" options:0 metrics:metrics views:viewsDictionary];
有帮助吗?

解决方案

For some reason Xcode was not giving me any kind of stack trace and was instead defaulting to sigabrting. I solved this by wrapping the code into try/catch blocks and breaking on the catch handler which then properly output my error.

其他提示

use this:

NSArray *constraints =[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-inset-[self.backButton(==width)]|" options:0 metrics:metrics views:viewsDictionary];

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top