Invalid size from UITableView.SizeThatFits ()

I implemented a UIPopoverController that is populated with a grouped UITableView. The number of cells in a table view can change dynamically while a popover is invisible. As soon as the popover becomes visible, the number of cells is fixed.

When the popover becomes visible, I resize the contents of the popover to the height of the table view. I use the SizeThatFits () method from the UITableView to get the size of the table and use this value to set the height of the PopoverContentSize.

This works great when the application is running. But always the first time a popover is displayed after a new application launch, SizeThatFits () provides the wrong height (from 60 pixels to high). Can anyone understand what this problem could be?

+4
source share
2 answers

I had a somewhat similar problem because I was doing my calculations in ViewDidLoad. I was able to work around the problem by creating a bool flag in the view code and performing calculations in ViewDidAppear if the flag was not set (and, of course, set the flag so that the logic would not be repeated every time).

+2
source

On iOS 5 and above, sizeThatFits in a UITableView gives the correct result when calling the viewDidLayoutSubviews UIViewController method.

+1
source

Source: https://habr.com/ru/post/1379957/


All Articles