0
votes

i have own class which is extends from UITableViewController.
After this line
MyClass *obj = [[MyClass alloc] init];
i have
obj.view.frame.orign.y = 20

after i push this custom view via navigation controller - i check y coordinate in viewDidAppear and it became 0.
so strange

Why ? Is it because my custom table view below status bar which height is 20 ?
or something else.
If it because status bar, why i can create UIButton in (0,0) and it below status bar ?

1

1 Answers

0
votes

The behavior that you see is normal:
- You first create your view controller, it is not attached to a view hierarchy, by default it takes the coordinate as if it was the root controller, y=20 because of the status bar
- Then you push the view controller, it is resized to fit in the navigation controller, the frame coordinates are the coordinates in relation to the parent frame , i.e. y=0 is the top of the navigation controller, which is equivalent to y=20 in the main window. pushViewController resizes the frame, see documentation http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

The view is automatically resized to fit between the navigation bar and toolbar (if present) before it is displayed.