自动布局让我的生活变得困难.从理论上讲,当我切换时它会非常有用,但我似乎总是在打架.
我做了一个演示项目试图找到帮助.有没有人知道如何在调整视图大小时使视图之间的间距均匀增加或减少?
这是三个标签(手动间隔垂直):

我想要的是让他们在旋转时均匀地调整间距(而不是视图大小).默认情况下,顶视图和底视图朝中心方向挤压:

自动布局,尽管它是好的,让我疯狂的约束.我有在IB设计的肖像模式,但我无法获得所需的横向方向.

请注意,当方向更改为横向时,UIImageView块之间的间距会减小,并且SAMPLE TEXT更改的文本对齐方式会右对齐.
目前,我已经为它添加了一些限制.但是,我需要保持UIImageView块之间的空间固定,因此它看起来像肖像和景观中的精细.我需要将它均匀地分布在肖像中并在景观中压缩(如上图所示).同样,目前我的约束会调出文本,但它不会将其保持在屏幕的中心并且右对齐.
自动布局可以实现这一点吗?如果是这样,怎么样?非常感谢.
我正在使用Autolayout以编程方式使用UiScrollview和UIPagectontrol创建应用程序
我创建了 TKScroller作为UIView的子类,我使用Some Mode和Array初始化它.
TKScroller.m
-(void)setData{
[self layoutIfNeeded];
CGRect mainFrame=self.frame;
[self layoutIfNeeded];
CGRect mainFrame=self.frame;
UIView *lastview;
NSMutableArray* manualConstraints = [NSMutableArray array];
for (int i=0; i<arrayData.count ; i++)
{
CGRect frame;
frame.origin.x = scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = scrollView.frame.size;
UIView *subview = [UIView new];
subview.backgroundColor = [self getRandomColor];
[scrollView addSubview:subview];
if (i==0)
{
NSLayoutConstraint* b1_top = [NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:scrollView attribute:NSLayoutAttributeTop multiplier:1 constant:5];
[manualConstraints addObject:b1_top];
NSLayoutConstraint* b1_left = [NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:scrollView attribute:NSLayoutAttributeLeading multiplier:1 constant:5]; …Run Code Online (Sandbox Code Playgroud) autolayout ×3
ios ×3
ios6 ×1
iphone ×1
objective-c ×1
rotation ×1
spacing ×1
uiscrollview ×1
xcode ×1