Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何以编程方式将垂直约束绑定到视图?_Ios_Ios7_Nslayoutconstraint - Fatal编程技术网

Ios 如何以编程方式将垂直约束绑定到视图?

Ios 如何以编程方式将垂直约束绑定到视图?,ios,ios7,nslayoutconstraint,Ios,Ios7,Nslayoutconstraint,我正在阅读如何在我的应用程序中实现iAd。 苹果提供了一个基本的横幅 将解决方案移植到UITableViewController时出现问题。由于我不使用任何xib文件将引入的NSLayoutConstraint绑定到我的tableview: @property (nonatomic, strong) IBOutlet NSLayoutConstraint *bottomConstraint; 如果未正确绑定,我将无法根据广告大小缩小视图: - (void)layoutAnimated:(BOO

我正在阅读如何在我的应用程序中实现iAd。 苹果提供了一个基本的横幅

将解决方案移植到UITableViewController时出现问题。由于我不使用任何xib文件将引入的NSLayoutConstraint绑定到我的tableview:

@property (nonatomic, strong) IBOutlet NSLayoutConstraint *bottomConstraint;
如果未正确绑定,我将无法根据广告大小缩小视图:

- (void)layoutAnimated:(BOOL)animated
{
    CGRect contentFrame = self.view.bounds;

    // all we need to do is ask the banner for a size that fits into the layout area we are using
    CGSize sizeForBanner = [_bannerView sizeThatFits:contentFrame.size];

    // compute the ad banner frame
    CGRect bannerFrame = _bannerView.frame;
    if (_bannerView.bannerLoaded) {

        // bring the ad into view
        contentFrame.size.height -= sizeForBanner.height;   // shrink down content frame to fit the banner below it
        bannerFrame.origin.y = contentFrame.size.height;
        bannerFrame.size.height = sizeForBanner.height;
        bannerFrame.size.width = sizeForBanner.width;

        // if the ad is available and loaded, shrink down the content frame to fit the banner below it,
        // we do this by modifying the vertical bottom constraint constant to equal the banner's height
        //
        NSLayoutConstraint *verticalBottomConstraint = self.bottomConstraint;
        verticalBottomConstraint.constant = sizeForBanner.height;
        [self.view layoutSubviews];

    } else {
        // hide the banner off screen further off the bottom
        bannerFrame.origin.y = contentFrame.size.height;
    }

    [UIView animateWithDuration:animated ? 0.25 : 0.0 animations:^{
        _contentView.frame = contentFrame;
        [_contentView layoutIfNeeded];
        _bannerView.frame = bannerFrame;
    }];
}
问题是如何通过编程将底部约束绑定到视图的垂直底部,以便在之后缩小它