I'm missing an obvious point on my code but I'm not able to see where.
TermsViewController *termsVC = [[TermsViewController alloc] init];
termsVC.signUpVC = self;
[self presentViewController:termsVC animated:YES completion:nil];
When the method presentViewController
is called, I can see that the method viewDidLoad
is called on my TermsViewController
but there is nothing execpt a black screen.
When I had termsVC.view.backgroundColor = [UIColor greenColor];
I can see a green screen. When I looked deeply with the debugger, I can see that my controller is initialized but my components (UITextField + UIButton) are nil
.
I thought that the presentViewController
was loaded the view linked to the controller but finally not.
Here is my TermsViewController:
#import "TermsViewController.h"
@interface TermsViewController ()
@end
@implementation TermsViewController
@synthesize signUpVC;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = [[NSString alloc] initWithFormat:@"Test"];
acceptButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
// Do any additional setup after loading the view.
}
You need to load your view controller from the storyboard, try this:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"<YourStoryboardFileName>"
bundle:nil];
TermsViewController *termsVC = [storyboard instantiateViewControllerWithIdentifier:@"<TermsViewController Storyboard ID>"];
termsVC.signUpVC = self;
[self presentViewController:termsVC animated:YES completion:nil];