gpt4 book ai didi

objective-c - 希望在现有的 UITabBarController 中创建 UINavigationView 或 UITableView

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

因此,我使用 UITabBarController 应用程序的模板来创建应用程序,但我发现自己处于无法解决的情况。我希望创建我的最后一个 View (具有 FourthViewController 类的 viewcontroller4 实例),使其实际上成为 UITableViewController/UITableView/或 UINavigationController。我真的无法判断哪一个最适合我的需要。

基本上它应该是一个带有表格 View 的信息屏幕,您可以点击单元格并选择不同的 View (设置、关于应用程序、帮助、电子邮件支持)。关于如何实现这一点有什么想法吗?我尝试用 UINavigation Controller 替换列出的 UIViewController (viewcontroller4)。

下面是我的appdelegate.m代码供引用:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1, *viewController2, *viewController3, *viewController4;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:nil];
viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:nil];
viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController_iPhone" bundle:nil];
viewController4 = [[FourthViewController alloc] initWithNibName:@"FourthViewController_iPhone" bundle:nil];
} else {
viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPad" bundle:nil];
viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPad" bundle:nil];
viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController_iPad" bundle:nil];
viewController4 = [[FourthViewController alloc] initWithNibName:@"FourthViewController_iPad" bundle:nil];
}
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, viewController4, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;}

最佳答案

不确定您如何尝试创建UINavigationController,但它会正常工作。创建 View Controller 后,请执行以下操作:

UINavigationController *navController = [[UINaviagtionController alloc] initWithRootViewController:viewController4];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, navController, nil];
// rest of your code

关于objective-c - 希望在现有的 UITabBarController 中创建 UINavigationView 或 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8570382/

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