-->

从切换到的UIViewController的UITabBarController(Switching

2019-08-03 22:20发布

我试着去展现一个UIViewController对于之前的UITabBarController 2秒,我知道我必须让我的弗洛姆的appdelegate。 我用尽2秒重新分配我的self.window.rootviewcontroller我UITabViewController后第一次分配我self.window.rootviewcontroller我的UIViewController,并用计划的计时器。

问题是,当我测试了一下,我的ViewController显示出来,但在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;  

}

Answer 1:

您的应用程序崩溃,因为你的选择有一个冒号它(changeView :)然而,该方法不后。 只是删除冒号。 此外,也没有必要有一个伊娃定时器或甚至指定计时器创建的任何东西 - 这条线可以只是:

[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(changeView) userInfo:nil repeats:NO];


文章来源: Switching from UIViewController to UITabBarController