我正在尝试更改xcode 4上的选项卡式应用程序以合并没有情节提要的导航控制器。第一个选项卡包含一个表格。这是需要导航的。
这是 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 个选项卡。但是第一个选项卡只是一个描绘导航控制器的空白黑屏,但没有应有的表格视图。
有什么我错过的吗?
谢谢..