带有两个UITextView的“autoresizingMask”问题

时间:2013-10-30 21:48:48

标签: ios resize uitextview overlap autoresizingmask

我遇到了两个UITextView的“autoresizingMask”问题。当我调整两个UITextViews的大小时,重叠第二个上面的第一个。 我附上了一张图片来解释这个问题。

谢谢!

enter image description here

更新:我把死亡代码

[UIView的]

self.autoresizesSubviews = YES;

// Configure title label
_titleLabel = [[UILabel alloc] init];
_titleLabel.frame = CGRectMake(4.0, 4.0, self.bounds.size.width - 8.0, 33.0);
_titleLabel.backgroundColor = APP_COLOR(1.0);
_titleLabel.font = FONT_LATO_BOLD(18.0);
_titleLabel.textColor = [UIColor whiteColor];
_titleLabel.textAlignment = UITextAlignmentCenter;
[self addSubview:_titleLabel];

// Question textView
_questionTextView = [[UITextView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(_titleLabel.bounds), (usableHeight / 2.0) - 4.0)];
_questionTextView.layer.cornerRadius = 8.0;
_questionTextView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
[self addSubview:_questionTextView];    

// Answer textView
_answerTextView = [[UITextView alloc] initWithFrame:CGRectMake(CGRectGetMinX(_questionTextView.frame), CGRectGetMaxY(_questionTextView.frame) + 8.0, CGRectGetWidth(_questionTextView.bounds), (usableHeight / 2.0) - 4.0)];
_answerTextView.layer.cornerRadius = 8.0;
_answerTextView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
[self addSubview:_answerTextView];

1 个答案:

答案 0 :(得分:0)

autoresize工作正常。

这两个视图在父视图中不合适。

您必须手动调整视图高度。