我正在创建一个带有标签栏控制器的iPad应用程序,需要登录.所以在启动时,我想显示一个LoginViewController,如果登录成功,则显示标签栏控制器.这就是我实现初始测试版本的方法(遗漏了一些典型的标题内容等)......
AppDelegate.h:
@interface AppDelegate_Pad : NSObject
<UIApplicationDelegate, LoginViewControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end
Run Code Online (Sandbox Code Playgroud)
AppDelegate.m:
@implementation AppDelegate_Pad
@synthesize window;
@synthesize tabBarController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
LoginViewController_Pad *lvc = [[LoginViewController_Pad alloc] initWithNibName:@"LoginViewController_Pad" bundle:nil];
lvc.delegate = self;
[window addSubview:lvc.view];
//[lvc release];
[window makeKeyAndVisible];
return YES;
}
- (void)loginViewControllerDidFinish:(LoginViewController_Pad *)loginViewController {
[window addSubview:tabBarController.view];
}
- (void)dealloc {...}
@end
Run Code Online (Sandbox Code Playgroud)
LoginViewController_Pad.h:
@protocol LoginViewControllerDelegate;
@interface LoginViewController_Pad : UIViewController {
id<LoginViewControllerDelegate> delegate; …Run Code Online (Sandbox Code Playgroud)