I hava a question about screen transition.
To transit a screen, I often use presentViewController method.
NextViewController *nextViewController = [[NextViewController alloc] init];
nextViewController.view.frame = CGRectMake(10, 10, 200, 400);
[self presentViewController:nextViewController animated:YES completion:nil];
However, the view.frame setting that I implemented is not applied.
Following code runs correctly.
NextViewController *nextViewController = [[NextViewController alloc] init];
[self presentViewController:nextViewController animated:YES completion:nil];
nextViewController.view.frame = CGRectMake(10, 10, 200, 400);
What's the difference of these code? Is view.frame redefined in presentViewController method?
Thanks.
NextViewController *nextViewController = [[NextViewController alloc] init];
nextViewController.view.frame = CGRectMake(10, 10, 200, 400);
[self presentViewController:nextViewController animated:YES completion:nil];
The above code is not working because you are setting the view of nextViewController which not yet created.
so in your next code you load the view controller first and then change the frame of the loaded view.
=========================EDIT===========================
If you want to set the frame in the view controller directly then bind your view with a IBOutlet
and then in
- (void) viewDidAppear:(BOOL)animated
{
//set the frame here
self.myView.frame = CGRectMake(10, 10, 200, 400);
}
Hope it helps :)
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