gpt4 book ai didi

iphone - 使用 xcode 4 在 ios 5 中创建选项卡式导航应用程序的问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:15:56 25 4
gpt4 key购买 nike

我正在尝试更改 xcode 4 上的选项卡式应用程序以合并没有 Storyboard的导航 Controller 。第一个选项卡包含一个表格。这是需要导航的。

这里是FirstViewController.h

#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *storeDetailsTable;
}

@property (nonatomic, retain) UITableView *storeDetailsTable;
@property (nonatomic, strong) NSDictionary *resultData;
@property (nonatomic, strong) NSMutableArray *populatedStoreArray;
@property (nonatomic, strong) NSMutableArray *images;


@end

这是 NavController.h:

 #import <UIKit/UIKit.h>

@interface NavController : UINavigationController

@property (nonatomic,retain) IBOutlet UINavigationController * navController;

@end

因此,我将 NavController 用作 UIViewControllerSubclass,然后将其更改为上述内容。

AppDelegate.h:

#import <UIKit/UIKit.h>
@class NavController;

@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate> {
IBOutlet NavController *navController;
}

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;
@property (strong, nonatomic) IBOutlet NavController *navController;

@end

和 AppDelegate.m:

#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "NavController.h"

@implementation AppDelegate

@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
@synthesize navController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
navController = [[NavController alloc] initWithNibName:@"NavController" bundle:nil];
// 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:navController, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}

现在,当我构建并运行它时,我看到了 2 个选项卡。但是第一个选项卡只是一个描绘导航 Controller 的空白黑屏,但没有应有的表格 View 。

有什么我遗漏的吗?

谢谢..

最佳答案

在您的代码中,我看不到您正在初始化 FirstViewController 类并让 NavController 知道它。 NavController 需要使用 RootViewController 进行初始化,例如:

NavController *myNavController = [[NavController alloc] initWithRootViewController:yourFirstViewController];

查找更多信息的好地方是: http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

关于iphone - 使用 xcode 4 在 ios 5 中创建选项卡式导航应用程序的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10258708/

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