My App 是一个底部有 TabBar 的 iOS 应用程序。我希望 iAd 放置在 TabBar 上方。
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
[adView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.view addSubview:adView];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:adView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:0]];
日志显示:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x7c94f90 h=--- v=--- V:[UIWindow:0x9a52530(568)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7c93910 h=-&- v=-&- UILayoutContainerView:0x7c71920.height == UIWindow:0x9a52530.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7c925c0 h=-&- v=-&- UITransitionView:0x7c71dd0.height == UILayoutContainerView:0x7c71920.height - 49>",
"<NSAutoresizingMaskLayoutConstraint:0x7c90ef0 h=-&- v=-&- UIViewControllerWrapperView:0x7868ef0.height == UITransitionView:0x7c71dd0.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7c8fb20 h=-&- v=-&- UILayoutContainerView:0x7868190.height == UIViewControllerWrapperView:0x7868ef0.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7c8e740 h=-&- v=-&- UINavigationTransitionView:0x7868b40.height == UILayoutContainerView:0x7868190.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7c8d020 h=-&- v=-&- UIViewControllerWrapperView:0x7e66780.height == UINavigationTransitionView:0x7868b40.height - 64>",
"<NSAutoresizingMaskLayoutConstraint:0x7c8be10 h=-&- v=-&- UIView:0x7e606d0.height == UIViewControllerWrapperView:0x7e66780.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7c8a670 h=-&- v=--& V:[ADBannerView:0x9d471f0(50)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7c8a630 h=-&- v=--& ADBannerView:0x9d471f0.midY == + 25>",
"<NSLayoutConstraint:0x7e656d0 ADBannerView:0x9d471f0.bottom == UIView:0x7e606d0.bottom>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7e656d0 ADBannerView:0x9d471f0.bottom == UIView:0x7e606d0.bottom>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
我该如何解决这个错误?