【问题标题】:Issue with "autoresizingMask" with two UITextViews带有两个 UITextView 的“autoresizingMask”问题
【发布时间】:2013-10-30 21:48:48
【问题描述】:

我对带有两个 UITextView 的“autoresizingMask”有疑问。当我调整两个 UITextViews 的大小时,第一个重叠在第二个之上。 我附上了一张图片来解释这个问题。

谢谢!

更新:我放了revenant代码

[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];

【问题讨论】:

  • 如果没有更多关于如何设置蒙版以及如何调整视图大小的详细信息,将很难提供帮助。使用相关代码更新您的问题。
  • rmaddy,我更新了答案。谢谢!

标签: ios resize uitextview overlap autoresizingmask


【解决方案1】:

自动调整大小工作正常。

这两个视图在父视图中无法组合在一起。

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

【讨论】:

  • 好的,谢谢!我将尝试将视图添加到“容器”视图并一起调整它们的大小
猜你喜欢
  • 1970-01-01
  • 2013-03-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-23
相关资源
最近更新 更多