編輯:工作,請參閱下面的代碼。UINavigationController在運行編譯時不顯示
在一個應用程序上工作,現在我有AppDelegate
類和一個自定義UINavigationController
類。我現在的代碼非常簡單,我覺得我已經正確設置了XIB
。構建成功,沒有錯誤。但是當應用程序啓動時,導航控制器不會顯示。我沒有看到導航欄和表格視圖。我看到的只是一個空白的屏幕。這裏是我的大部分代碼:
//
// FTPPhotosAppDelegate.h
// FTPPhotos
//
// Created by Aaron McLeod on 11-05-30.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "RootViewController.h"
@interface FTPPhotosAppDelegate : NSObject <UIApplicationDelegate> {
UINavigationController *navigationController;
RootViewController *rootViewController;
}
@property (nonatomic, retain) UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) RootViewController *rootViewController;
@end
//
// FTPPhotosAppDelegate.m
// FTPPhotos
//
// Created by Aaron McLeod on 11-05-30.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "FTPPhotosAppDelegate.h"
@implementation FTPPhotosAppDelegate
@synthesize window=_window;
@synthesize navigationController, rootViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
navigationController = [[UINavigationController alloc] init];
rootViewController = [[RootViewController alloc] init];
[self.navigationController pushViewController:rootViewController animated:NO];
[self.window addSubview:[self.navigationController view]];
[self.window makeKeyAndVisible];
return YES;
}
@interface RootViewController : UITableViewController<UIImagePickerControllerDelegate> {
NSMutableArray *photos;
UIImagePickerController *picker;
UIBarButtonItem *addPhotoButton;
}
@property (nonatomic, retain) NSMutableArray *photos;
@property (nonatomic, retain) UIImagePickerController *picker;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *addPhotoButton;
- (void) loadPhotos;
- (IBAction) addPhoto;
- (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize;
@end
#import "RootViewController.h"
@implementation RootViewController
@synthesize photos, picker, addPhotoButton;
- (void)viewDidLoad
{
self.photos = [[NSMutableArray alloc] initWithCapacity:50];
[self loadPhotos];
[super viewDidLoad];
}
任何想法?以下是XIB
,
的屏幕截圖。
讓我知道你是否需要更多信息。
您可以發佈NIB文件的圖像,其左側有對象層次結構列表嗎? –
完成:http://img148.imageshack.us/img148/189/nib.png我也將添加到帖子中。 – agmcleod
說阻止登錄 –