IOS中登陆界面如何跳转到含tabbar的界面
2016-03-24 22:15
337 查看
简单实现方法:项目建立在tabbarcontroller的基础上。
在appdelegate的
方法中,使用
这样,你打开程序,首先显示的登陆页面,点击登陆,在登陆的事件中加上下述代码
这样就实现了你想要的效果。
稍微麻烦点的方法:你的项目建立在singleview的基础上(单一viewController)。再写一个otherTabBarController,
点击登陆就使用
otherTabBarController要继承自UITabBarController,这样就没有底部挡住的问题。
最初我给的答案是使用继承自UIViewController的方法。
不过我觉得这样写的代码层次会有些冗余。不如直接继承自UITabbarController作为容器。
用系统的tabbarcontroller会挡住,至于原因因为系统的这套TabBarController.view的尺寸是320*480,而默认建立的singleview项目,是有statusBar的20像素存在,这样,viewController的尺寸是320*460,而在这个的基础上addSubview的尺寸(320*480)大于本身,自然按照左上角对齐,就导致向下偏移20像素。
当然你也可以在AppDelegate的
中加上
解决偏移的问题。
在appdelegate的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
方法中,使用
[self.tabBarController presentModalViewController:loginNC animated:NO];
这样,你打开程序,首先显示的登陆页面,点击登陆,在登陆的事件中加上下述代码
[self dismissModalViewControllerAnimated:YES];
这样就实现了你想要的效果。
稍微麻烦点的方法:你的项目建立在singleview的基础上(单一viewController)。再写一个otherTabBarController,
UIViewController *vc1 = [[[UIViewController alloc] init] autorelease]; vc1.view.backgroundColor = [UIColor redColor]; UIViewController *vc2 = [[[UIViewController alloc] init] autorelease]; vc2.view.backgroundColor = [UIColor blueColor]; [self setViewControllers:[NSArray arrayWithObjects:vc1,vc2, nil]];
点击登陆就使用
[viewController presentModalViewController:otherTabBarController animated:YES];
otherTabBarController要继承自UITabBarController,这样就没有底部挡住的问题。
最初我给的答案是使用继承自UIViewController的方法。
不过我觉得这样写的代码层次会有些冗余。不如直接继承自UITabbarController作为容器。
用系统的tabbarcontroller会挡住,至于原因因为系统的这套TabBarController.view的尺寸是320*480,而默认建立的singleview项目,是有statusBar的20像素存在,这样,viewController的尺寸是320*460,而在这个的基础上addSubview的尺寸(320*480)大于本身,自然按照左上角对齐,就导致向下偏移20像素。
当然你也可以在AppDelegate的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
中加上
[[UIApplication sharedApplication] setStatusBarHidden:YES];
解决偏移的问题。
相关文章推荐
- iOS奇葩BUG:蓝色小圆点
- iOS奇葩BUG:蓝色小圆点
- iOS中delegate代理对象使用weak和assign哪个
- iOS开发中代码块的使用
- IOS开发之GitHub优秀源码分享/优秀第三方转载
- iOS-滤镜
- IOS 数组/字典转json串
- 十大ios开发者喜爱的开源库
- 十大ios开发者喜爱的开源库
- 中文 iOS/Mac 开发博客列表
- iOS调试奇巧淫技(二)之LLDB
- ios copy/strong/weak..使用总结
- HDOJ 1017 A Mathematical Curiosity
- HDOJ 1017 A Mathematical Curiosity
- iOS 官方文档阅读顺序整理
- iOS事务的基本概念
- iOS资源汇总(开源项目、第三方库、技术博客等)
- iOS开发之滤镜 滤镜链 保存到本地相册 以及学习滤镜的诀窍
- iOS 怎样限定界面的旋转
- 工作中常用的第三方框架