我试图在 UITabBarController 之前显示 UIViewController 2 秒,我知道我必须从我的应用程序代理中获取它。我尝试过首先将我的 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;
}
您的应用程序正在崩溃,因为您的选择器后面有一个冒号(changeView:),而该方法却没有。只需删除该冒号即可。另外,不需要为计时器提供 ivar,甚至不需要将计时器创建分配给任何东西——该行可以是:
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(changeView) userInfo:nil repeats:NO];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)