I have a library project, and an app project (that uses the library project).
For a particular method of a library, it will check if user exists in the system or not then popup a pre-created form to let user registers. But this is no direct way as it needs to show this form on behalf of the user's application thus an app project in this case.
App project has one storyboard (utilize UINavigationController). A library project also has one storyboard which contains independent UIViewControllers ie. registration form etc allowing user's application to invoke via library's method to show them during runtime.
I bundle the library's storyboard, and I can access it successfully in app project. The code below shows when I got response back, and tries to show registration form which is not success.
So the question is how to properly show UIViewController from another Storyboard as a modal on top of current UIViewController (in this case UINavigationController).
// check if user exists in the system or not
[self player:playerId withBlock:^(PBPlayer_Response *player, NSURL *url, NSError *error) {
// user doesn't exist
if(player == nil && error != nil && error.code == 200)
{
NSLog(@"Player doesn't exist");
dispatch_async(dispatch_get_main_queue(), ^{
// get the bundle from the library
NSBundle *pbBundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"pblibResource" withExtension:@"bundle"]];
// get playbasis's storyboard
UIStoryboard *pbStoryboard = [UIStoryboard storyboardWithName:@"PBStoryboard" bundle:pbBundle];
// get regis ui-view-controller
pbUserRegistrationFormViewController *regisForm = [pbStoryboard instantiateViewControllerWithIdentifier:@"registrationFormViewController"];
// ----> show registration form - didn't show the form!
[[[[UIApplication sharedApplication].keyWindow rootViewController] navigationController] presentViewController:regisForm animated:YES completion:nil];
});
}
// player exists
else if(player != nil && error == nil)
{
...
}
// error
else
{
...
}
}];