Im using Auto layout with Size classes enabled.
I want to fetch data as soon as possible and it works fine doing this in:
override func viewDidLoad() {
super.viewDidLoad()
fetchData()
}
The problem is that the frame is not yet calculated and gives a frame of i.e 600x600 which is the canvas size in storyboard. This means that if I want to place a custom loader in the center by using:
self.loader.center = self.view.center
This will make the loader be place someplace far away from the center.
I can fix the loader placement by calling fetchData in:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
fetchData()
}
But this makes it fetch more than only one time. So my question is: When should I fetchData(), I want it to happen as early as possible. Only one time, and I want to loader to be centered.
Thanks
Edit: Disabling Auto Layout or Size classes is not an option.