I have a MyAppAppDelegate, it contains a window, and a UITabBarController.
@interface MyAppAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
IBOutlet UITabBarController *rootController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *rootController;
@end
And I have View A, that contain a button to switch to View B. It is the .h file:
#import <UIKit/UIKit.h>
@class MyAppAppDelegate;
@class ViewBController;
@interface ViewAController : UIViewController {
IBOutlet UIView *view;
IBOutlet UIButton *switchToViewBButton;
}
@property (retain, nonatomic) UIView *view;
@property (retain, nonatomic) UIButton *switchToViewBButton;
-(IBAction) startSwitching: (id)sender;
@end
And it is the.m file:
#import "ViewAController.h"
#import "ViewBController.h"
#import "MyAppAppDelegate.h"
@implementation ViewAController
/*skip the default generated codes*/
-(IBAction) startClock: (id)sender{
NSLog(@"Start Switching");
[rootController presentModalViewController:ViewBController animated:YES];
}
Plz notice that the ViewB is not enable to display on UITabBarController, it only appear, when the ViewA button is clicked. Also, I found that the debugger tell me that the rootController is undeclared. but I already import MyAppDelegate to the file. thz a lot... ...