Load an XIB from a view controller of another XIB (iPhone)
This is my first post and I'm pretty new to this stuff but here is my question and I hope you can help :)
So I made a game screen and now want to add a Main Menu to the beginning. So I added a new View Controller Subclass and now have an IBAction that is from a button that will load the game screen.
#import <UIKit/UIKit.h>
@interface MainMenuViewController : UIViewController{
IBOutlet UIButton *classicMode;
IBOutlet UIButton *timedMode;
}
@property (nonatomic, retain) IBOutlet UIButton *classicMode;
@property (nonatomic, retain) IBOutlet UIButton *timedMode;
- (IBAction) classicModeButton:(id) sender;
- (IBAction) timedModeButton:(id) sender;
@end
So now I went into my .m and set the IBAction
- (IBAction) classicModeButton:(id)sender{
}
But I've tried using initWithNibName and specifying my other view controller xib, and it runs with no errors, but when I tap the button I have linked in IB it always crashes and says that it received the signal SIGABRT. Any help would be gr开发者_JAVA百科eatly appreciated. :)
You are probably hitting the problem described in this post. You need to set your controller as self.window.rootViewController instead of adding it as subview of the self.window in your app delegate code.
You need to post more of your code but you most likely need to create a navigation controller to push the view controller onto. The navigation controller manages the transition of views so is necessary to perform switches from one view to another.
精彩评论