2013-03-29 70 views
0

首先,我正在使用故事板进行导航。我已经到了一个地步,我正在一个菜单屏幕上显示4个不同的视图(仅使用导航控制器),我希望它检查用户是否已登录,如果不是,我希望LoginViewController /视图提出。我对客观的c/xcode非常陌生,并且在寻找解决方案后,这就是我所想到的。我不知道如何将它与我的程序联系起来。这只是需要链接到我的按钮,或者我完全与我现在在做什么?检查用户登录故事板前的场景登录

if (self.appDelegate.userHasActiveLogin) { 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController2"]; 
    [vc setModalPresentationStyle:UIModalPresentationFullScreen]; 

    [self presentModalViewController:vc animated:YES];} 
else { 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginController"]; 
    [vc setModalPresentationStyle:UIModalPresentationFullScreen]; 

    [self presentModalViewController:vc animated:YES]; 
} 
+0

只是一个提示,如果你还没有发现这一点,斯坦福在iTunes上的ios开发课程u:https://itunes.apple.com/us/course/coding-together-developing/id593208016 它真的速度了解ios开发的过程,讲座非常优秀 – Andreas

+0

更新您在〜2小时前提出的原始问题,而不是创建一个新的问题。 http://stackoverflow.com/questions/15708904/verifying-login-before-loading-view-controller – rog

回答

1

你可以做的是在你的故事板中创建手动节点。

从菜单控制器(橙色符号)按住Ctrl键拖动到子控制器,选择按下。点击segue并在属性检查器中给它一个标识符。现在您可以检查用户是否已登录,然后在菜单的VC中有条件地呼叫[self performSegueWithIdentifier:@"logged in segue" sender:self];

条件是,所有的风险投资家必须在同一个故事板,但我怀疑是这样。