Reputation: 565
I work in xcode 4.6.2 with ios 6, using arc and storyboards. I created a MainStoryboard.storyboard In here I created 2 viewcontrollers: SplashViewController and WalkthroughViewController. With segues I go from one to the other. In WalkthroughViewController I created 2 views: 1 scrollview which covers 370 height from top and another view for login module which covers 110 height from bottom.
Now I would like to separate the logic of these two modules. Because I may reuse the login module and the walkthrough will be a scrollview which will be automated by the images that are in a plist file.
I tried to create a uiviewcontroller called LoginViewController with an xib file and connected the view to my WalkthroughViewController dragging and dropping it to my .h file. I called it loginView. The xib file of the login view has 2 buttons called "facebook login" and "skip login".
@property (strong, nonatomic) IBOutlet UIView *loginView;
And in the .m file I tried to initialize this view using the initwithnibname method so:
self.loginView = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil].view;
The app now works without crashing but the screen is empty.
Any ideas why my view is not being assigned or doesn't seem like it should? I don't see the facebooklogin or skiplogin buttons at all..
Thank you.
Upvotes: 0
Views: 100
Reputation: 156
you better not write like this:
self.loginView = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil].view;
better use whole viewController like:
loginView = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
and you can make loginView is viewController not a view and add- bringSubviewToFront to make loginView visible
Upvotes: 1
Reputation: 156
have you tried to set the frame? something like:
self.loginView = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil].view;
CGRect loginViewFrame = CGRectMake(0, self.view.frame.size.height-110, self.view.frame.size.width, 110);
[self.view addSubview:loginView];
loginView.frame = loginViewFrame;
Upvotes: 1