У меня есть позиция UIImageView, зависящая от iAdBanner. Я получаю ошибку:LayoutConstraint error при программной настройке динамического uiimageview
"<NSLayoutConstraint:0x17409eb40 UIImageView:0x1741e9200.bottom == UIView:0x17418d270.bottom - 100>",
"<NSLayoutConstraint:0x174281e00 UIImageView:0x1741e9200.bottom == UIView:0x17418d270.bottom - 50>"
Любые идеи о том, что вызывает это? Ниже приведен код для установки uiimageview и в зависимости от того, загружается ли iAd или нет, устанавливается высота.
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sunshine.png"]];
CGRect frame = imgView.frame;
frame.size.width = 180;
frame.size.height = 30;
imgView.frame = frame;
imgView.translatesAutoresizingMaskIntoConstraints = NO;
[imgView setContentMode:UIViewContentModeScaleAspectFit];
[imgView sizeToFit];
[self.view addSubview:imgView];
[self.view addConstraint:[NSLayoutConstraint
constraintWithItem:imgView
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTrailing
multiplier:1.0
constant:6.0]];
_imgView = imgView;
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
[self.view addConstraint:[NSLayoutConstraint
constraintWithItem:_imgView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:-100.0]];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
[self.view addConstraint:[NSLayoutConstraint
constraintWithItem:_imgView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:-50.0]];
}
Показать ограничения и журнал ошибок. Это поможет нам больше. – Jassi
Вам необходимо указать возникшую ошибку _full_, а также любой код, который вы используете для создания ограничений, или скриншот ограничений в вашем раскадровке. Но из-за этого звука у вас есть два противоречащих друг другу ограничений, которые не могут работать так, как вы этого хотите. –