iOS 7 contentSize not calculated properly

1.4k views Asked by At

My app does some element placement based on contentSize property. However I have found out that iOS 7 doesn't calculate it properly until viewDidLoad method is called. Setting text in text view is done in viewDidLoad however all positioning is done in viewWillAppear. All of it was working until iOS7. Is there a way to calculate positions of elements before they are displayed to user?

1

There are 1 answers

0
Snowmanzzz On

In viewDidLoad, you shouldn't do much geometry stuff. "You should not initialise UI geometry-related things in viewDidLoad, because the geometry of your view is not set at this point and the results will be unpredictable."

I find a workaround.

You have string, then you can use a NSString method (though deprecated in iOS7) to get it's size, then you have a close height, you can plus 50 or some other value.