//
// MyGameViewController.h
//
#import < UIKit/UIKit.h >
#import "SecondViewController.h"@interface MyGameViewController : UIViewController {
IBOutlet SecondViewController *secondViewController;
}
-(IBAction)goToSecondView;
@end//
// MyGameViewController.m
//
#import "MyGameViewController.h"@implementation MyGameViewController
-(IBAction)goToSecondView{
[self presentModalViewController:secondViewController animated:YES];
}//
// MyGameView.h
//
#import < UIKit/UIKit.h >
#import "Sprite.h"@interface MyGameView : UIView {…}
Currently I have implemented a button on the MyGameView.xib to invoke the secondViewController view and it works. But I want the secondViewController get invoked by programming inside MyGameView.m when there is interruption, not by pressing a button. Therefore, I think there are 2 approaches:
a) Either make the goToSecondView method available to MyGameView.m
b) Implement all the code in MyGameViewController.h and MyGameViewController.m to MyGameView.m.
Issues:
1) When tried to make a) happen, I have to make goToSecondView method starting with (void), not (IBAction). But then how to invoke it in MyGameView.m?
2) I tried to do b) and implemented all code to MyGameView.m. But presentModalViewController is a method of ViewController and does not work in UIView. So what is the solution?