Iphone 无法将模态视图控制器完全显示在选项卡栏控制器的顶部
我正在创建一个选项卡式iPhone应用程序。当应用程序启动时,如果用户未登录,则应在选项卡栏控制器的顶部显示一个模式视图(因此看起来这是第一个屏幕)。登录后,模式视图滑开,显示其后面的选项卡栏控制器 不幸的是,当我从应用程序代理内部调用Iphone 无法将模态视图控制器完全显示在选项卡栏控制器的顶部,iphone,ios,objective-c,Iphone,Ios,Objective C,我正在创建一个选项卡式iPhone应用程序。当应用程序启动时,如果用户未登录,则应在选项卡栏控制器的顶部显示一个模式视图(因此看起来这是第一个屏幕)。登录后,模式视图滑开,显示其后面的选项卡栏控制器 不幸的是,当我从应用程序代理内部调用[self.tabBarController presentViewController:self.loginViewController animated:NO completion:NULL]时,我仍然可以看到屏幕底部的选项卡。我需要保险 具有讽刺意味的是,在
[self.tabBarController presentViewController:self.loginViewController animated:NO completion:NULL]
时,我仍然可以看到屏幕底部的选项卡。我需要保险
具有讽刺意味的是,在寻找解决方案时,我发现大多数人都遇到了反问题
我注意到,如果我没有将窗口的rootViewController设置为uitabarcontroller,只将其视图作为窗口的子视图插入,那么它就会按预期工作,但Xcode抱怨缺少rootViewController。这是怎么回事
我的应用程序代理的-application:didfishlaunchingwithoptions:
方法如下所示
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self registerDefaults];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = @[
[self makeSellingListingsController],
[[[UIViewController alloc] init] autorelease], // stub
[[[UIViewController alloc] init] autorelease], // stub
[[[UIViewController alloc] init] autorelease] // stub
];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.window.rootViewController = self.tabBarController;
[self.window addSubview:self.tabBarController.view];
[self presentLogin]; // this doesn't cover the tabs, but it should
[self.window makeKeyAndVisible];
return YES;
}
- (void)presentLogin
{
[self.tabBarController presentViewController:[[[FLLoginViewController alloc]
initWithNibName:@"FLLoginViewController"
bundle:[NSBundle mainBundle]] autorelease]
animated:NO
completion:NULL];
}
不要从选项卡栏控制器中显示它,而是从第一个选项卡中的根控制器的ViewDidDisplay方法中显示它。如果将“否”传递给动画参数,则启动应用程序时,首先会看到模式屏幕。我这样做时也会遇到同样的问题。。。选项卡仍然可见。我一定是配置不正确。@d11wtq,我不知道该说什么。它对我有用。您将演示文稿从应用程序代理中取出,并将其移动到第一个视图控制器?如果用户未登录,为什么要以模态方式打开登录屏幕,然后将其设置为rootcontroller。