我是IOS和Objective C開發新手。我試圖從Web上加載JSON並將其解析爲多級菜單。點擊下一步按鈕後,用戶將被引導至另一個屏幕。 我目前有基本的應用程序中的數據加載到類RootViewController:UITableViewController。 我想在上面顯示導航欄,其中將包含下一個屏幕按鈕。 我已經嘗試了很多選項,但在每個人都沒有顯示導航欄(導航欄本身在那裏,但沒有標題或任何按鈕)。我有基本的XIB,其中只有對象下的tableview。IOS導航欄始終爲空
任何指針我該怎麼做。
示例代碼(RootViewController.m): -
(void)viewDidLoad
{
DBGS;
[super viewDidLoad];
//This Failed self.navigationController.navigationItem.rightBarButtonItem=self.navigationController.editButtonItem;
[email protected]"My Title";
//This Also Failed
UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationController.navigationItem.backBarButtonItem = _backButton;
[email protected]"My Title";
[_backButton release];
//Remaining Code
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"contents" ofType:@"json"];
self.model = [[TreeListModel alloc] initWithJSONFilePath:filePath];
}
頭文件(RootViewController.h)
#import <UIKit/UIKit.h>
#import "TreeListModel.h"
@interface RootViewController : UITableViewController {
UINavigationController *navigationController;
}
@property (nonatomic, retain) TreeListModel *model;
@property (strong, nonatomic) UINavigationController *navigationController;
@property (strong, nonatomic) UIWindow *window;
@end
我無法發佈應用圖片。但在o/p屏幕tableview有(正確填充)+藍色NavBar(無標題或按鈕)。
感謝
做你如何設置你的'window'和'self.navigation'控制器?我懷疑你錯過了什麼。由於不需要在'RootViewcontroller'中聲明'navigationController' – NeverHopeless