基于故事板的登录屏幕示例 [英] Example for login screen modally based on storyboard

查看:23
本文介绍了基于故事板的登录屏幕示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 ios/xcode 并且遇到了障碍.

I am learning ios/ xcode and at a roadblock.

我有一个基于 tabbarcontroller+navigation 的设计.如果用户未登录,我需要显示一个登录屏幕.这是基本的层次结构.登录页面需要一个导航栏(因为我遵循的教程在栏上放置了一个Go"按钮.

I have a tabbarcontroller+navigation based design. I need to present a login screen if user is not logged in. Here is the basic heirarchy. The login page needs a navigationBar (as the tutorial I followed puts a "Go" button on the bar.

LoginController: (LTController.h,.m)

Main View:TabBarController>
                   NavigationController>View1>View1a
                   NavigationController>View2

我在这里阅读了很多关于模态视图、委托方法等的帖子.其中大部分是代码片段,不幸的是对于我的初学者来说有点过头了.

I read lot of posts here on modal view, delegate method, etc. Most of them are code snippets which unfortunately are a bit over the head for my beginner level.

希望能简单解释一下如何实现这一点.特别是关于哪些文件需要更改的注释会很棒.

Would appreciate a simple explanation as to how to achieve this. Espacially a note on which files needs changes would be great.

谢谢

推荐答案

这里是场景.它是如此简单.我只是希望它会有用.

Here is scenario . Its so simple . I just hope that it will be useful.

对于 UITableBarController,给 storyboard id

For the UITableBarController give a name for identity to storyboard id

然后在您的 ViewController 类文件中您拥有正确的身份验证凭据 >.?在那边做一些验证.然后按照此代码.效果很好

Then in your ViewController class file You have the authentication credentials right >.? Do some stuff over there for authentication . then follow this code . It works fine

- (IBAction)Login:(id)sender {

    if(authenticated)  // authenticated---> BOOL Value assign True only if Login Success
        {
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
            UITabBarController *obj=[storyboard instantiateViewControllerWithIdentifier:@"tab"];
            self.navigationController.navigationBarHidden=YES;
            [self.navigationController pushViewController:obj animated:YES];
        } 

这篇关于基于故事板的登录屏幕示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆