Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call ViewController's method to show 2nd View?
    primarykey
    data
    text
    <blockquote> <p>//<br> // MyGameViewController.h<br> //<br> #import &lt; UIKit/UIKit.h ><br> #import "SecondViewController.h" </p> <p>@interface MyGameViewController : UIViewController {<br> IBOutlet SecondViewController *secondViewController;<br> }<br> -(IBAction)goToSecondView;<br> @end </p> <hr> <p>//<br> // MyGameViewController.m<br> //<br> #import "MyGameViewController.h" </p> <p>@implementation MyGameViewController </p> <p>-(IBAction)goToSecondView{<br> [self presentModalViewController:secondViewController animated:YES];<br> }</p> <hr> <p>//<br> // MyGameView.h<br> //<br> #import &lt; UIKit/UIKit.h ><br> #import "Sprite.h"</p> <p>@interface MyGameView : UIView {…}</p> </blockquote> <p>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: </p> <p>a) Either make the goToSecondView method available to MyGameView.m<br> b) Implement all the code in MyGameViewController.h and MyGameViewController.m to MyGameView.m. </p> <p>Issues:<br> 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?<br> 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?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload