Hi i am trying to add a view controller
as a child view
. and later remove this view controller
form parent view.I am using following code for this purpose.
self.loginView = [self.storyboard instantiateViewControllerWithIdentifier:@"LOGIN"];
[self.view addSubview:self.loginView.view];
This code works fine for iOS8
but in iOS7
this code is not working it shows the half of the screen.On half part login is shown.
What could be the solution for this??
Adding a
UIViewController
as asubView
is not standard programming I believe,UIViewController
is intended to handle a complete view on screen. Instead of adding aUIViewController
to yourUIView
you should create a customUIView
and then use thatUIView
to achieve whatever results you want to.EDIT : Use XIB to create a custom UIView.
Add a custom
UIView
object in your main view (in XIB) in which you want to add and show your child view controller. LetcontentView
is the name of that view. Use following code to add child view controller:if you don't add last line, your child view controller will not receive events. By using this code you can simultaneously receive events in both parent and child view controllers.