gpt4 book ai didi

ios - 选项卡式应用程序不会显示登录 View

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

我在 Xcode 4.3 中有一个标签栏应用程序,我试图在显示标签栏之前插入一个登录屏幕。如果presentModalViewController,应用程序运行正常有animated:YES但如果没有动画,则 View 不会显示。

@synthesize window = _window;

@synthesize tabBarController = _tabBarController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;

LogInViewController *logViewController = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil];
[self.window addSubview:_tabBarController.view];

[self.tabBarController presentModalViewController:logViewController animated:YES];
//This wont work
//[self.tabBarController presentModalViewController:logViewController animated:NO];

[self.window makeKeyAndVisible];
return YES;

}

-(void)loginDone{

NSLog(@"back to the app delegate");
[self.tabBarController dismissModalViewControllerAnimated:YES];


}
  1. 这样做正确吗?
  2. 为什么代码不能使用 animated:NO
  3. 我也在输出中得到这个 Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x689d350> .

最佳答案

首先,在 View Controller 设置之前移动 [self.window makeKeyAndVisible];

此外,您应该在首先可见的 View Controller 的 viewWillAppear: 方法中显示模态视图 Controller ,以确保您的应用 View 层次结构在显示您的登录之前已完全初始化屏幕。

关于ios - 选项卡式应用程序不会显示登录 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10896191/

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