I have a View with UINavigationBar: AppDelegate:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
_homeScreen = [[PrepareScreen alloc] init];
self.mainViewController = [[MyViewController alloc] initWithScreenDef:[self.homeScreen projectHomeScreen] AndBounds:self.window.bounds];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.mainViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
And then i have a class
MyViewController : UIView <UITableViewDataSource,UITableViewDelegate>
And in my .h file i have:
- (void)viewDidLoad
{
[super viewDidLoad];
self.myTableView = [[UITableView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:self.myTableView];
}
After that i have a wrong height of a screen. I want that my myTableView have a size.height-49.0
Init the tableView with CGRectZero in viewDidLoad method and then in the method viewWillAppear: set the self.myTableView.frame as in this method the view's geometry is already set and self.view.bounds will be correct. So in general: init views in viewDidLoad, but set their geometry in viewWillAppear:.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With