gpt4 book ai didi

ios - 使用 TabBarController 的 SimpleDrillDown 示例

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

我一直在尝试 Apple 的 SimpleDrillDown 示例,并尝试将其放入选项卡栏中。问题是 View 现在不显示,我知道是应用程序委托(delegate)中的以下代码导致了它。我正在努力更改它以适应选项卡栏,并且希望得到一些指示。

- (void)applicationDidFinishLaunching:(UIApplication *)application {

// Create the data controller and pass it to the root view controller.
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
RootViewController *rootViewController = (RootViewController *)[[navigationController viewControllers]objectAtIndex:0];

DataController *controller = [[DataController alloc] init];
rootViewController.dataController = controller;
self.dataController = controller;
}

我已将其替换为以下内容,但此行 EatCatTVC *rootViewController = (RootViewController *)[[navigationController viewControllers]objectAtIndex:0]; 抛出错误

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UITabBarController *tabBar = (UITabBarController *)self.window.rootViewController;
// Create the data controller and pass it to the root view controller.

EatCatTVC *rootViewController = (RootViewController *)[[navigationController viewControllers]objectAtIndex:0];
DataController *controller = [[DataController alloc] init];
rootViewController.dataController = controller;
self.dataController = controller;
return YES;
}

最佳答案

您的代码失败,因为您正在访问不存在的对象

EatCatTVC *rootViewController = (RootViewController *)[[navigationController viewControllers]objectAtIndex:0];

这一行navigationController在您的“修改”版本中不存在。

确保“rootController”设置为UITabBarController类(我假设您确实在Interface Builder中设置了它)。

然后使用 setViewControllers:animated:UITabBarController' 实例提供(例如)UIViewController` 实例。

关于ios - 使用 TabBarController 的 SimpleDrillDown 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11951326/

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