I want to be able (as an exercise for training for controllers) to have a button in the initial view that I configure, then if you click on the button, an action will take place that changes the view from view 1 to view 2. I don’t know how it you? See the section in the code below where I would like to introduce code that does this.
Can I post the code I need? (i.e. will cover how to refer to the variable I set in AppDelegate). Let me know if this exercise I gave myself is ruined somewhere. Thank.
AppDelegate * .h
#import <UIKit/UIKit.h>
@class gregsController;
@class Gregs2ndController;
@interface windowsBasedAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
gregsController *viewController;
Gregs2ndController *view2Controller;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet gregsController *viewController;
@property (nonatomic, retain) IBOutlet Gregs2ndController *view2Controller;
@end
AppDelegate * .m
#import "windowsBasedAppDelegate.h"
#import "gregsController.h"
#import "Gregs2ndController.h"
@implementation windowsBasedAppDelegate
@synthesize window;
@synthesize viewController;
@synthesize view2Controller;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"windowsBasedAppDelegate - didFinishLaunchingWithOptions");
[self.window addSubview:view2Controller.view];
[self.window makeKeyAndVisible];
return YES;
}
User controller * .m
#import "gregsController.h"
@implementation gregsController
- (IBAction)logSomething {
NSLog(@"About to switch views");
[self.view removeFromSuperview];
NSLog(@"Finished switching views");
}
source
share