任何机构都尝试了一个场景,例如第一次显示登录屏幕,验证用户名后,应用程序以uitabbar控制器启动。带登录屏幕的UITabbarControl
我试着用uitabbar的应用程序只。将登录屏幕作为tabbar控制器中的第一个视图,并且使用“TabBarController.tabBar.hidden = TRUE;”但视图会变形(tabbar的空间仍然是空的),这里有人可以帮助我正确显示视图吗?
感谢, abhayadev小号
任何机构都尝试了一个场景,例如第一次显示登录屏幕,验证用户名后,应用程序以uitabbar控制器启动。带登录屏幕的UITabbarControl
我试着用uitabbar的应用程序只。将登录屏幕作为tabbar控制器中的第一个视图,并且使用“TabBarController.tabBar.hidden = TRUE;”但视图会变形(tabbar的空间仍然是空的),这里有人可以帮助我正确显示视图吗?
感谢, abhayadev小号
已经在的firstView登录页面只有导航第二种观点controller.Thats之后controller.Add使用TabBar的窗口。
一切顺利。
另一种可能性是将登录viewController显示为模式viewController。模态VC隐藏标签栏。
创建另一个viewController(例如LoginViewController)。在的applicationDidFinishLaunching AppDelegate中:加(isLogged只是为了为例):
if (self.isLogged) {
[window addSubview:self.tabBarViewController.view];
} else {
LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:@"login" bundle:nil];
[window addSubview:loginVC.view];
}
你应该调用方法时,登录成功,消除loginVC视图和窗口上添加tabBarController.view。
没有比这更复杂的了。
应用程序只需要使用LoginViewController,直到用户通过身份验证,注册并链接到FB或其他内容,然后该LoginViewController应该被释放,因为它不再需要。这个解决方案可能看起来过于夸张,但我认为它很好。下面是我的做法,在我的情况下,我只是有一个闪屏,显示一些信息,然后用户去应用程序的主要部分:
首先,我实际上做了一个简单的协议,我可以在我的MainAppDelegate.m文件,名为SplashDelegate:
//SplashDelegate.h
@protocol SplashDelegate <NSObject>
- (void) splashExit : (id) sender;
@end
然后我的MainAppDelegate实现了。首先在应用程序启动后,self.window
的rootViewController
将指向我的SplashViewController,然后关闭后,MainViewController
(在OP的情况下,他的TabViewController
)将被实例化。
这是我主要的应用程序代理的重要组成部分h
文件:
#import "SplashDelegate.h"
@class MainViewController;
@class SplashViewController;
@interface MainWithLoginPageAppDelegate : NSObject <UIApplicationDelegate, SplashDelegate> {
MainViewController *_viewController;
UIWindow *_window;
SplashViewController *_splashViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet MainViewController *viewController;
@property (nonatomic, retain) IBOutlet SplashViewController *splashViewController;
而且m
文件的重要组成部分:
#import "MainWithLoginPageAppDelegate.h"
#import "MainViewController.h"
#import "SplashViewController.h"
@implementation MainWithLoginPageAppDelegate
@synthesize window=_window;
@synthesize viewController=_viewController;
@synthesize splashViewController = _splashViewController;
- (void) splashExit : (id) sender
{
_viewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[_splashViewController release];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//initialize my splash controller
_splashViewController = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil];
self.splashViewController.parentDelegate = self;
self.window.rootViewController = self.splashViewController;
[self.window makeKeyAndVisible];
return YES;
//note that _viewController is still not set up... it will be setup once the login phase is done
}
然后,所有你需要的SplashViewController
(或LoginViewController
)是您的登录测试和parentDelegate
的财产。在SplashViewController.h
的内部,我使parentDelegate
为一个实例变量,如id <SplashDelegate> _parentDelegate
。另一个好主意是扩展上面的协议,以减轻检查用户登录的责任,以便不检查视图控制器类内部的登录。
编辑:在LoginViewController
内部,然后,您可以拨打[self.parentDelegate splashExit:self]
,并修改上面的想法以包括您的登录检查。
希望这对别人有帮助!