我有UIViewController
两个UIScrollView
标签和一个按钮:
UIView
-UIScrollView
-UILabel
-UILabel
-UIButton
我需要动态对齐我的UILabels
和UIButton
之后,因为每个视图都可以有不同的大小。UILabels
没关系,但我UIButton
进入第二个中间UILabel
这是我的代码:
self.header.text = event.title;
self.header.numberOfLines = 0;
CGFloat headerHeight = [event.title sizeWithFont:[UIFont fontWithName:@"Arial" size:20] constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:UILineBreakModeWordWrap].height;
self.header.frame = CGRectMake(19, 20, 280, headerHeight);
CGFloat positionY = 40 + [self.header.text sizeWithFont:[UIFont fontWithName:@"Arial" size:20] constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:UILineBreakModeWordWrap].height;
CGFloat descriptionHeight = [event.descr sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:UILineBreakModeWordWrap].height;
self.descr.frame = CGRectMake(19, positionY, 280, descriptionHeight);
self.descr.text = event.descr;
self.descr.numberOfLines = 0;
positionY = self.descr.frame.origin.y + self.descr.frame.size.height + 40;
buyButton.frame = CGRectMake(19, positionY, 72, 37);
scrollView.contentInset = UIEdgeInsetsMake(contentInset, 0, 0, 0);
[scrollView setContentSize:CGSizeMake(320, positionY+80)];
UIScrollView 在 IB 中设置了灵活的高度自动调整掩码。
这是它的外观:
谁能告诉我我做错了什么?
更新:
如果我删除 UIScrollView 的自动调整大小掩码 - 一切正常