Reputation: 919
I am using Storyboard successfully. One screen isn't "empty", it has a class NotifierViewController.
This class has a .h,.m and XIB File. The app runs wonderfully.
Now I need a button in the XIB File to link this view back to my Storyboard. Right now, I have to stop and restart the app to see the main view.
So in the IB I created a UIButton and a IBAction in the .h and .m file. But my code for the actions doesn't run. I get a black screen only.
The view that is the "Initial View Controller" in my Storyboard has the Class ViewController (only .h and .m File)
What is wrong?
#import "NotifierViewController.h"
#import "ViewController.h"
- (IBAction)home:(id)sender {
NSLog(@"Button was tapped");
// init & alloc - Replace with your custom view controllers initialization method (if applicabale)
ViewController *viewController = [[ViewController alloc] init];
[viewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:viewController animated:YES completion:NULL];
[ViewController release];
}
Upvotes: 0
Views: 2169
Reputation: 6614
- (IBAction)home:(id)sender
{
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController* initialHelpView = [storyboard instantiateInitialViewController];
initialHelpView.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:initialHelpView animated:YES];
}
Upvotes: 0
Reputation: 3131
You shouldn't reinitialize and represent your main "root" view. If are you presenting this NotifierViewController is presented modally, you can just dismiss it:
- (IBAction)home:(id)sender {
[self dismissModalViewControllerAnimated:Yes];
}
If NotifierViewController isn't being presented modally, let me know how and I'll edit my answer.
Upvotes: 1