Pregunta

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];
¿Fue útil?

Solución

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.

Otros consejos

use this:

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top