我试图在 UITabBarController 之前显示一个 UIViewController 2 秒,我知道我必须从我的 appdelegate 中制作它。我试过首先将我的 self.window.rootviewcontroller 分配给我的 UIViewController,并在 2 秒后使用预定的计时器将我的 self.window.rootviewcontroller 重新分配给我的 UITabViewController。
问题是当我测试它时,我的视图控制器出现了,但在 2 秒后应用程序崩溃了。
这是我的 LaMetro_88AppDelegate.h
@interface LaMetro_88AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>
{
UIView *startupView;
NSTimer *timer;
UIViewController *LoadingViewController;
UITabBarController *tabBarController;
}
-(void)changeView;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) IBOutlet UIViewController *LoadingViewController;
@end
这是我的 LaMetro_88AppDelegate.m
@implementation LaMetro_88AppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
@synthesize LoadingViewController = _LoadingViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.LoadingViewController;
timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(changeView:) userInfo:nil repeats:NO];
[self.window makeKeyAndVisible];
return YES;
}
-(void)changeView
{
self.window.rootViewController = self.tabBarController;
}