У меня была такая же проблема, и мне потребовалось несколько часов, чтобы найти подходящее решение для нее ... Вот что я придумал ...
-(void)DidBecomeActive {
if (!DidUpdateBounds) {
DidUpdateBounds = true; // instance variable set to false on load
NSString *oldtext = uiTextView.text;
//The trick is (1) removing it from it's superview
// (2) resetting it's 'text' property
// (3) re-adding it to the view WHILE it's on-screen.
[uiTextView removeFromSuperview];
uiTextView.text = oldtext;
[self.view addSubview:uiTextView];
[self.view setNeedsDisplay];
}
}
Я использую CoreAnimation , чтобы переключиться на это представление. Поэтому перед тем, как выполнить этот код, я называю это
//The 0,-300,480,300 is bounds of the UIView my offscreen UITextview is on
[self.view.layer setBounds:CGRectMake(0, -300, 480, 300)];
// SetNeedsDisplay, then call my method above to
//FORCIBILY redrew the UITextView while it's effectively on-screen
[self.view setNeedsDisplay];
[TextLogVC DidBecomeActive];
//CoreAnimation then goes here
Это решает проблему. После установки layer.bounds он перерисовывает элемент управления (UITextView
) и думает, что он на экране. Затем CoreAnimation позаботится об анимации моего текущего UIView
до нового UIView
, и весь текст в uiTextView будет отображаться во всей анимации.