0

您好我正在尝试将集合视图中的项目添加到同一屏幕上的 uiview。当用户点击一个单元格时,我找到并把它放到下面的 mycreationview 中(我还希望用户在这些添加的 uiimages 周围移动)。而且我在顶部有一个工具栏可以返回等。现在,当我点击单元格 3 次时,添加了 3 个图像以进行查看,但随后工具栏消失并且其上的后退按钮隐藏到顶部/左侧,只有四分之一可见,怎么能我调试这个?

    myCollectionViewCell* cell=(myCollectionViewCell* ) [self.myCollectionView cellForItemAtIndexPath:index];
    UIImageView *iv = [[UIImageView alloc]initWithImage:cell.myCellImageView.image];
    iv.contentMode = UIViewContentModeScaleAspectFill;
    NSLayoutConstraint * constraint1 = [NSLayoutConstraint constraintWithItem:iv attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.myCreationView attribute:NSLayoutAttributeWidth multiplier:0.4f constant:0];
    NSLayoutConstraint * constraint2 = [NSLayoutConstraint constraintWithItem:iv attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.myCreationView attribute:NSLayoutAttributeHeight multiplier:0.4f constant:0];
    NSLayoutConstraint * constraint3 = [NSLayoutConstraint constraintWithItem:iv attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.myCreationView attribute:NSLayoutAttributeLeft multiplier:0 constant:10];
    NSLayoutConstraint * constraint4 = [NSLayoutConstraint constraintWithItem:iv attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.myCreationView attribute:NSLayoutAttributeTop multiplier:0 constant:10];

    [iv setTranslatesAutoresizingMaskIntoConstraints:NO];
    iv.autoresizesSubviews=YES;
    iv.userInteractionEnabled=YES;
    [self.myCreationView addSubview:iv];
    [self.myCreationView addConstraint:constraint1];
    [self.myCreationView addConstraint:constraint2];
    [self.myCreationView addConstraint:constraint3];
    [self.myCreationView addConstraint:constraint4];

4

1 回答 1

0

回答我的问题。我使视图变小了一点,并且不触摸工具栏,问题就消失了。所以我想如果他们互相接触就会产生一个约束。

于 2013-03-03T00:15:11.663 回答