gpt4 book ai didi

iOS : Fail to show Login prior to Tabs Successfully

转载 作者:行者123 更新时间:2023-11-29 10:46:55 25 4
gpt4 key购买 nike

我知道这个问题在 STackOverflow 上出现过很多次,在互联网上也出现过很多次。我也问过与相同相关的问题,但上下文不同,所以请耐心等待,因为我无法找到此任务的解决方案。

我正在使用 Xcode 5,使用 Storyboard。我的项目是基于选项卡的,并且在 Storyboard中添加了一个 LoginViewController。我的胜利是在选项卡之前显示 LoginViewController。我从各个站点尝试了几种方法,但没有任何效果。使用此代码,我首先可以获取 LoginViewController,但无法获取 Tabs Controller 。在我的 AppDelegate 中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
self.tabBarController = [[MC_MainTabBarController alloc] init];

LoginViewController *loginViewController = [storyboard instantiateViewControllerWithIdentifier:@"loginViewController"];
[self.window setRootViewController:loginViewController];

// This also works - it shows the login
//[[[[UIApplication sharedApplication] delegate] window] setRootViewController:loginViewController];

// With this Login doesn't come only
//[loginViewController setModalPresentationStyle:UIModalPresentationFullScreen];
//[tabCtrler presentViewController:loginViewController animated:NO completion:nil];

return YES;
}

在我的 LoginViewController.m - 最后的 loginBtnClicked 事件中,我调用:

    NSLog(@"Showing TabController");
MC_AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.window setRootViewController:appDelegate.tabBarController];

执行上述几行时,出现黑屏和以下警告:

Showing TabController
Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation.
Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation.

谁能帮帮我。从过去的两天开始,我就被困在这个问题上了。

非常感谢任何帮助。

最佳答案

你确定 MC_MainTabBarController 是 UITabBarController 的子类吗? (我猜是)因为当 TabBar 不是 rootViewController 时会出现这个错误

代替[[MC_MainTabBarController alloc] init];我将从 Storyboard [storyboard instantiateViewControllerWithIdentifier:@"myTabBarIdentifier"];

我试过了,它对我有用:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
_tabController = [storyboard instantiateViewControllerWithIdentifier:@"tabbcontrolllerid"];
LoginViewController *login = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:nil];
[_window setRootViewController:login];
return YES;
}

在登录按钮里喜欢你

- (IBAction)goToApp:(id)sender {
stackAppDelegate *app = [UIApplication sharedApplication].delegate;
[app.window setRootViewController:app.tabController];
}

有关信息,标签栏是自定义的 TabBarController,它是 UITabBarController 的子类我在 Storyboard 中设置了我的自定义标签栏的标识符。

关于iOS : Fail to show Login prior to Tabs Successfully,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22092249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com