我想问一个关于iPhone应用程序的问题。我写了一个会显示一个表的程序。但是,我不知道为什么我无法在表格中显示导航标题。下面是我的代码无法在iPhone应用程序的表格中显示导航标题
//代码
- (void)viewDidLoad {
[super viewDidLoad];
// control flow, call another user define function and add the items to the table
[self flowControl];
//Set the title
self.navigationItem.title = @"Table Title Hello";
// can see
// NSLog(@"self.navigationItem.title: %@", self.navigationItem.title);
}
表只能显示项,但不是标题。谁能帮我?
// ----------更新1 --------------
在[自流量控制]的代码将调用两个功能,这两者的功能是添加项目,例如[displayNameArray addObject:@"John Chan"];
// ---------- Update 2 --------------- 在我的程序中,是2个视图控制器。
1)MyViewController
2)SimpleTableView
第一个是用来让用户输入的信息,第二个是用于显示在表格式的内容。
我的项目名称是USERPROJECT
//The following is the content of the .m
#import "MyViewController.h"
#import "USERPROJECT.h"
#import "SimpleTableView.h"
@implementation USERPROJECT
@synthesize window;
@synthesize myViewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
[self setMyViewController:aViewController];
[aViewController release];
UIView *controllersView = [myViewController view];
[window addSubview:controllersView];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
- (void)dealloc {
[myViewController release];
[window release];
[super dealloc];
}
@end
而且它是“MyViewController.m”,我用它来从“MyViewController.m”切换到控制“SimpleTableView中的内容之一。 m'
- (void) switchPageShowTable {
NSLog(@"%d: switchPageShowTable", order);
order++;
SimpleTableView *simpleTableView = [[SimpleTableView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:simpleTableView animated:YES];
}
它是否会影响在调用标题中使用'self'?非常感谢你。
感谢您的回复。我尝试将代码放在SimpelTableView.h中,但收到很多错误。我应该在哪里放置代码? – Questions 2010-07-21 01:16:34
第一块代码替换了你在switchPageShowTable中的代码(我认为它是MyViewController的方法)。请注意,我的版本释放模态视图控制器,以便您不必在别处跟踪它。 “self.title”部分是SimpleTableView的职责,可能会进入init ...或viewDidLoad。顺便说一下,SimpleTableView的名称有点混乱,我将其命名为SimpleTableViewController类。 – Costique 2010-07-21 04:58:56