Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use a ViewController as a AppDelegate?
    primarykey
    data
    text
    <p>I made a book for children. Every page is a ViewController. In the beginning, I did all the switching of the ViewControllers in the AppDelegate, but after having troubles with AutoRotation i did all the switching in another ViewController called ViewControllerSwitch. Before, the code was like this. In the AppDelegate:</p> <pre><code>- (void)goToNextPage3 { self.view3 = [[[ViewController3 alloc] init] autorelease]; view3.view.frame = CGRectMake(769, 0, 768, 1024); [window addSubview:view3.view]; [UIView …SomeAnimationStuff...];   [UIView setAnimationDidStopSelector:@selector(animationDidStop3:finished:context:)]; }  - (void)animationDidStop3:(NSString *)animationID finished:(NSNumber *)finished context: (void *)context { [self.view1a.view removeFromSuperview]; self.view1a = nil; } </code></pre> <p>And here is the code from one of my view controllers ("pages") called ViewController1a:</p> <pre><code>- (void)buttonClicked { MyBookAppDelegate* next2 =(MyBookAppDelegate *) [[UIApplication sharedApplication] delegate]; [next2 goToNextPage3]; } </code></pre> <p>This worked like a charm.</p> <p>Now all my switching is in ViewControllerSwitch. How should I change the code in ViewController1a to access goToNextPage3?</p> <p>I tried this:</p> <pre><code> - (void)buttonClicked { ViewControllerSwitch* next2 = (ViewControllerSwitch *) [[UIApplication sharedApplication] delegate]; [next2 goToNextPage3]; } </code></pre> <p>It gives me a SIGABRT at [next2 goToNextPage3].</p> <p>Any ideas?</p> <p><strong>Update:</strong> </p> <p>i am still trying, so now i did this:</p> <p>in my Viewcontroller1a.h:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "ViewControllerSwitch.h" @class ViewController2; @class ViewControllerSwitch; @protocol ViewController1Delegate; @interface ViewController1a : UIViewController { id&lt;ViewController1aDelegate&gt;myDelegate; } @property(nonatomic, assign)id&lt;ViewController1Delegate&gt;myDelegate; @end @protocol ViewController1Delegate -(void)goToNextPageV; @end </code></pre> <p>and in my .m file:</p> <pre><code>- (void)buttonClicked { [self.myDelegate goToNextPageV]; } </code></pre> <p>i know there is something missing in the ViewControllerSwitch but i don´t know what.</p>
    singulars
    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