2012-04-21 10 views
2

xcode 4でタブ付きアプリケーションを変更しようとしましたが、ストーリーボードなしのナビゲーションコントローラが組み込まれました。 最初のタブには表が含まれています。これはナビゲート可能である必要があるものです。 xcode 4のios 5でタブ付きナビゲーションアプリを作成する際の問題

はここ
#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 

FirstViewController.h

です。ここNavController.hです:だから

#import <UIKit/UIKit.h> 

    @interface NavController : UINavigationController 

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

    @end 

、私はUIViewControllerSubclassとしてからNavControllerを使用して、上記にそれを変更しています。

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つのタブを参照してください。しかし、最初のタブは、ナビゲーションコントローラーを描いた空白の黒い画面ですが、必要なテーブルビューはありません。

私が見逃したことはありますか?あなたのコードで

おかげ..

答えて

3

私はあなたがFirstViewControllerクラスをINITING、それはからNavControllerに知られて作っていることを確認することはできません。 NavControllerは次のように、RootViewControllerとinitにする必要があります: http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

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

より多くの情報を見つけるのに良い場所であります

関連する問題