以编程方式向UIImageView添加约束条件
问题描述:
UPDATE:这似乎与自动布局没有任何关系。即使我禁用自动布局我仍然得到同样:(以编程方式向UIImageView添加约束条件
我加入了一系列UIImageView
s到滚动视图,并花费数小时试图诊断 问题后,我得出它有结论,是指被推动的约束问题,我UIImage
s下降,请参阅所附图片:
正如你可以看到UIImage
s的推下来,我已经标志着UIScrollView
红色背景我也有附上我的UIScrollView
的约束图片:
这里是我的滚动视图的属性:
如何获得有关设置的UIImageView
,使其在UIScrollView
水平为中心的约束?我正在使用以下代码将图像填入UIScrollView
。
for (UIView *v in self.scrollview.subviews)
{
[v removeFromSuperview];
}
CGRect workingFrame = self.scrollview.frame;
workingFrame.origin.x = 0;
for(NSDictionary *dict in info)
{
UIImageView *imageview = [[UIImageView alloc] initWithImage:[dict objectForKey:UIImagePickerControllerOriginalImage]];
MyManager * myManager = [MyManager sharedInstance];
[myManager.assets addObject:imageview];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
imageview.frame = workingFrame;
[self.scrollview addSubview:imageview];
workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
}
[self.scrollview setContentSize:CGSizeMake(workingFrame.origin.x, workingFrame.size.height)];
答
workingFrame.origin.y = 0;修复它
redcolor是textview? – 2013-04-26 03:57:13
uiscrollview后面有一个textview,当点击顶部的uisegment按钮的“文本”时显示。 – jini 2013-04-26 03:59:41
红色是滚动视图 – jini 2013-04-26 04:06:35