无法为UIView设置新的位置

时间:2013-07-15 16:03:59

标签: ios uiview position

所以我的应用程序包含一个滚动视图,里面有一个文本视图。用户可以选择添加图像,当这样做时,UIImageView子类被添加到滚动视图中。当发生这种情况时,UITextView应向下移动以避开,但它不会这样做。我的代码如下:

 // add a subview to the scroll view; push text field down
textEditorImageView *imageSubview = [[textEditorImageView alloc] initWithFrame:self.scrollView.frame];

2013-07-15 12:36:41.652 iCloud Test[3600:c07] Scroll view: {{20, 87}, {280, 345}}
2013-07-15 12:36:41.653 iCloud Test[3600:c07] Image subview: {{20, 87}, {280, 345}}

[self.scrollView addSubview:imageSubview];

imageSubview.image = image; // this is where the frame of the image subview is set

 2013-07-15 12:36:41.653 iCloud Test[3600:c07] Image subview after setting frame: {{0, 0}, {280, 69}}

2013-07-15 12:36:41.654 iCloud Test[3600:c07] Main text field before setting frame: {{0, 0}, {280, 345}}
self.mainTextField.frame = CGRectMake(self.mainTextField.frame.origin.x, self.mainTextField.frame.origin.y + imageSubview.frame.size.height, self.mainTextField.frame.size.width, self.mainTextField.frame.size.height);   // does not work. I tried setting the origin to random numbers but the text view stays at the same position.

 2013-07-15 12:36:41.655 iCloud Test[3600:c07] Main text field after setting frame: {{0, 69}, {280, 345}}
[self.scrollView setNeedsDisplay];  // does not work with or without this

我的代码丢失了什么?提前谢谢!

编辑:为每行后的帧添加NSLogs

0 个答案:

没有答案