IOS 登陆判断问题
有一个登陆界面,还有一个包含多个选项卡的界面在ViewController.m中登陆按钮的代码如下
UIViewController *controller=[[Tabbarcontroller alloc]init];
[self presentModalViewController:controller animated:YES];
在TabbarController.h中
@property(strong,nonatomic) UITabBarController *controller;
然后是在TabbarController.m中的
@synthesize controller; -(id) initWithNibName(NSString *)nibNameOrNil bundle:(NSBundle *)nibBoundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBoundleOrNil];
UIViewController *first=[[First alloc]initWithNibName:@"First" bunlde:nil];
UIViewController *second=[[Second alloc]initWithNibName:@"Second" bunlde:nil];
controller=[[UITabBarController alloc]init];
controller.viewControllers=[NSArray arrayWithObjects:first,second,nil];
[self.view addSubView:controller.view];
if(self){ }
return self;
}
效果出来了 但是tabbar感觉是整体下移了一些位置(头部有一些空白,tabbar选项卡底部被遮盖了)
这个是什么原因呢?
简单实现方法:你的项目建立在tabbarcontroller的基础上。
在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 登陆判断问题的更多相关文章
- iOS 登陆的实现四种方式
iOS 登陆的实现四种方式 一. 网页加载: http://www.cnblogs.com/tekkaman/archive/2013/02/21/2920218.ht ml [iOS登陆的实现] A ...
- jQuery登陆判断简单实现代码
登陆判断在实际应用中还是比较常见,在客户端执行判断可以减少服务器端的负担,感兴趣的朋友可以参考下 复制代码代码如下: <script src="jquery-1.9.1.js" ...
- iOS - 正则表达式判断邮箱、身份证..是否正确:
iOS - 正则表达式判断邮箱.身份证..是否正确: //邮箱 + (BOOL) validateEmail:(NSString *)email { NSString *emailRegex ...
- ios如何判断键盘是否已经显示
ios如何判断键盘是否已经显示 在群里看到有人问:ios如何判断键盘已经显示在界面上. 其实这个解决很简单: 写一个单例来管理键盘的状态. 这个单例在初始化方法init种监听2个事件,分别是 UI ...
- iOS 登陆之使用ShareSDK
0. 概述 登陆要使用ShareSDK,可以实现多社交平台账号登陆,短信验证,并且都是永久免费的. 网址:www.mob.com 1.iOS 登陆之界面设置
- iOS开发 判断当前APP版本和升级
从iOS8系统开始,用户可以在设置里面设置在WiFi环境下,自动更新安装的App.此功能大大方便了用户,但是一些用户没有开启此项功能,因此还是需要在程序里面提示用户的 方法一:在服务器接口约定对应的数 ...
- IOS登陆+注册+抽奖+排行榜
要求:三个页面(登录页面,pickerView页面,排行榜页面),pickerView页面是三个组件,每个组件显示0-9,点击按钮进行随机,获得的值存入排行榜,排行榜显示大于500的最高的10个分数和 ...
- iOS ----------各种判断
iOS 判断数字 - (BOOL) deptNumInputShouldNumber:(NSString *)str { if (str.length == 0) { return NO; } NSS ...
- iOS:判断用户名是否以字母开头、手机号输入、邮箱是否正确的正则表达式
新建一个字符串分类:NSString(Check),定义类方法更方便 .h文件 #import <Foundation/Foundation.h> @interface NSString ...
随机推荐
- PostgreSQL简单介绍
自从MySQL被Oracle收购以后,PostgreSQL逐渐成为开源关系型数据库的首选. 本文介绍PostgreSQL的安装和基本用法,供初次使用者上手.以下内容基于Debian操作系统,其他操作系 ...
- RAC NTP/CTSS
本文總結主要參考: http://blog.itpub.net/23135684/viewspace-759693/ http://www.happyworld.net.cn/post/6.html ...
- PHPCMS V9 栏目列表调用文章点击量及评论数量方法
很多朋友在用Phpcms做站时,具体需要在列表页.首页调用文章列表调用文章的点击量和评论排行,那么怎么才能做到在Phpcms v9首页.频道页.列表页.推荐位等页面获取文章浏览量和评论统计呢? 原因起 ...
- sublime text 2 安装emmet插件
一.添加插件之前先 下载Package Control 按 Ctrl+`(就是~这个键) 复制下面的代码 确认 重新启动sublime text2 import urllib2,os;pf='Pack ...
- C[泊车管理系统]
// // main.c // 泊车管理系统 // // Created by 丁小未 on 13-7-14. // Copyright (c) 2013年 dingxiaowei. All ...
- APP交互
交互设计基本功!5个值得学习的APP交互方式http://www.uisdc.com/5-interactive-design-worth-learning 移动App交互设计10大趋势–你用到了吗? ...
- ajax调用WebServices服务方法和传参调用WebServices注意事项
先演示下ajax是如何调用WebServices中的方法 1.新建一个页面default.aspx,一个Web服务 在页面中引用jQuery文件. <script src=" ...
- Python基础9- 字典
#coding=utf8#字典由键和对应的值组成(键值对)--哈希表,字典元素也可以为空 dict1 = {'name':'kaly','age':20,'sex':'male'}dict2 = {} ...
- jetty 长时间运行之后出现 PWC6117 file not found
严重: PWC6117: File "%2Ftmp%2Fjetty-0.0.0.0-9090-admin.war-_admin-any-%2Fwebapp%2Ferror%2F404.jsp ...
- underscore.js依赖库函数分析二(查找)
查找: 在underscore.js封装了对dom查找的操作,find()和filter()函数,find()函数的查找操作是返回首个与条件相符的元素值,filter()函数是找到与条件相符的所有元素 ...