gpt4 book ai didi

iphone - iOS 标签栏不显示模态视图

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

我想在应用程序的开头显示模态视图,但它没有出现。这是我的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self initDataBase];
CustomerModel *customer = [[[CustomerPersistor alloc] init] getLoggedCustomer];

self.window.rootViewController = self.tabBarController;

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.

UIViewController *profileViewController = [[[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil] autorelease];
profileViewController.title = @"Profile";
UINavigationController *profileNavigation = [[[UINavigationController alloc] initWithRootViewController:profileViewController] autorelease];

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

[self.window makeKeyAndVisible];

if(customer == nil) { NSLog(@"HO");
ViewController *login = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
//login.delegate = self.tabBarController.view;

[self.viewController presentModalViewController:[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] animated:YES];
}
return YES;

}

我该如何解决?

最佳答案

首先,似乎没有设置 self.viewController 属性,并且您正在实例化同一个“ViewController”两次。这都是错误的:

ViewController *login = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 
//login.delegate = self.tabBarController.view;
[self.viewController presentModalViewController:[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] animated:YES];

尝试将此代码移动到您的 profileViewController 的 viewDidLoad 中...即让 TabBarController 与其第一个选项卡的 View Controller 一起加载。

关于iphone - iOS 标签栏不显示模态视图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12073324/

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