目标:在一定时间内显示一个启动屏幕(3秒),然后登录视图显示用于身份验证过程,如果此身份验证成功,则转到主页(许多应用程序(如facebook )都使用这种效果)。
我所做的是
MainViewController 1.将导航的根设置为
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.isLogIn = FALSE;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
MainViewController *mainView = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:mainView];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;}
LogInViewController 2.在 MainViewController中呈现作为modalViewController
@implementation MainViewController
-(void) viewDidLoad {
appDelegate = [[UIApplication sharedApplication] delegate];
LogInController *logInController = [[LogInController alloc] initWithNibName:@"LogInController" bundle:nil];
if ( !appDelegate.isLogIn )
[self presentModalViewController:logInController animated:NO];
}3.在splashScreen LogInViewController中呈现 as modalViewController
#implementation LogInViewController
-(void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Sign in";
SplashScreen *splashController = [[SplashScreen alloc] initWithNibName:@"SplashScreen" bundle:nil];
[self presentModalViewController:splashController animated:NO];
;
}}
4.在splashScreen中,在一定的时间之后解散自己
@implementation SplashScreen
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSelector:@selector(removeSplashScreen) withObject:nil afterDelay:6.0];
}
-(void)removeSplashScreen{
[self dismissViewControllerAnimated:YES completion:nil];
} Problem:显示日志视图,但在登录视图之前没有显示splashScreen。
我发现根本没有调用viewDidLoad of SplashScreen的方法。
有人能给我解释一下并指出我在这里错过了什么吗?欢迎在此发表所有意见。
发布于 2012-09-14 04:42:37
这样做是因为你的应用程序代表的引用有问题
@implementation MainViewController
-(void) viewDidLoad {
appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
LogInController *logInController = [[LogInController alloc] initWithNibName:@"LogInController" bundle:nil];
if ( !appDelegate.isLogIn )
[self presentModalViewController:logInController animated:NO];
}https://stackoverflow.com/questions/12418197
复制相似问题