ios7 +如何添加对uiimagepickercontroller cameraOverlay的禁区

时间:2014-12-18 14:07:45

标签: ios ios7 ios8 uiimagepickercontroller cameraoverlayview

我很惊讶。我没有找到任何远程解决SO问题的方法。我想象很多人可能在我面前试过了。这只能意味着一件事......它是微不足道的,我无法做到:(

如何向cameraOverlay添加约束?

我试过这个

UIView *overlayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
    [overlayView setBackgroundColor:[UIColor redColor]];
    [overlayView setAlpha:0.5];
    UILabel *Testlabel = [[UILabel alloc] init];
    [Testlabel setText:@"Hollllaaaaa in the overlay"];
    [overlayView addSubview:Testlabel];

    NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:overlayView
                                                                       attribute:NSLayoutAttributeCenterX
                                                                       relatedBy:NSLayoutRelationEqual
                                                                          toItem:Testlabel
                                                                       attribute:NSLayoutAttributeCenterX
                                                                      multiplier:1
                                                                        constant:0];

    [overlayView addConstraints:@[widthConstraint]];

    [self.picker setCameraOverlayView:overlayView];

但我收到错误Unable to simultaneously satisfy constraints。只有一个约束。

作为注释,选择器是具有约束并且定义良好的视图的一部分。我想知道我在initwithFrame覆盖视图的事实是否与自动布局不相关...如果是这样的话,我怎样才能简单地将约束添加到与屏幕尺寸相同的空白覆盖?

0 个答案:

没有答案