【发布时间】:2014-03-04 18:26:29
【问题描述】:
我是 IOS 和 Objective C 开发的新手。我试图从网络加载 JSON 并将其解析为多级菜单之类的东西。单击下一步按钮时,用户将被引导到另一个屏幕。 我目前有基本的应用程序,其中数据被加载到类 RootViewController 中:UITableViewController。 我想在它上面显示导航栏,其中将包含下一个屏幕按钮。 我尝试了很多选项,但每个人都没有在导航栏中显示任何内容(导航栏本身就在那里,但没有标题或任何按钮)。我有基本的 XIB,其中对象下只有表视图。
任何指针我该怎么做。
示例代码(RootViewController.m):-
(void)viewDidLoad
{
DBGS;
[super viewDidLoad];
//This Failed self.navigationController.navigationItem.rightBarButtonItem=self.navigationController.editButtonItem;
self.navigationController.navigationItem.title=@"My Title";
//This Also Failed
UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationController.navigationItem.backBarButtonItem = _backButton;
self.navigationController.navigationItem.title=@"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
标签: ios iphone objective-c xcode uitableview