首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能对模态视图控制器进行模态分析

不能对模态视图控制器进行模态分析
EN

Stack Overflow用户
提问于 2012-09-14 04:35:38
回答 1查看 116关注 0票数 0

目标:在一定时间内显示一个启动屏幕(3秒),然后登录视图显示用于身份验证过程,如果此身份验证成功,则转到主页(许多应用程序(如facebook )都使用这种效果)。

我所做的是

MainViewController 1.将导航的根设置为

代码语言:javascript
复制
- (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

代码语言:javascript
复制
@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

代码语言:javascript
复制
#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中,在一定的时间之后解散自己

代码语言:javascript
复制
@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的方法。

有人能给我解释一下并指出我在这里错过了什么吗?欢迎在此发表所有意见。

EN

回答 1

Stack Overflow用户

发布于 2012-09-14 04:42:37

这样做是因为你的应用程序代表的引用有问题

代码语言:javascript
复制
@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]; 
 }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12418197

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档