I am writing a custom keyboard for iOS 8. My main UIView returns {{0, 0}, {0, 0}}
in my viewDidLoad
method. I have tried receiving the CGRect with view.frame and bounds but both return 0. However if I use these same methods to retrieve my view's coordinates in the viewDidAppear
method they return fine: {{0, 0}, {320, 216}}
. The problem here is that viewDidAppear runs after didLoad so I cannot retrieve the size from didAppear and use it in didLoad. Here is my question:
Why does self.view 's frame return 0 in viewDidLoad
? Shouldn't its size be set already in here? This (viewDidLoad) is where I'm supposed to be doing most of my initiation and UI set up, correct? I have moderate experience in Xcode.
I am programming this in swift, although this shouldn't matter(?) I thought it was worth noting. Answers in Obj-C are fine.
Edit: I created an entirely new Xcode project and target with the following class and receive the same error:
import UIKit
class KeyboardViewController: UIInputViewController {
override func viewDidLoad() {
super.viewDidLoad()
println(self.view.frame) // returns (0.0,0.0,0.0,0.0)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func viewDidAppear(animated: Bool) {
println(self.view.frame) // returns (0.0,0.0,320.0,216.0)
}
}
I've tested with the simulator and physical devices too ranging from 6 to 4S. Nothing seems to make a difference.