1

だから私のアプリは、その中にテキストビューを持つスクロールビューで構成されています。ユーザーには画像を追加するオプションがあり、その際に 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 を追加

4

0 に答える 0