-1

可能重复:
从 UIViewController 切换到 UITabBarController

我试图在 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;  

}
4

2 回答 2

0

因为该changeView方法不带参数,所以它的方法签名不包含冒号。将选择器更改为changeView不带冒号:

@selector(changeView)
于 2012-12-12T00:08:40.927 回答
0

改变这个:

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

对此:

timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(changeView) userInfo:nil repeats:NO];
于 2012-12-12T00:09:43.077 回答