在审查现有答案时,我认为Steve's question and codelark's answer是我最关心的问题。但我在这里错过了一些东西。在模态视图中设置导航项目标题
我对模式的看法厦门国际银行: IFDNewFormViewController.xib:
View Controller
> Table View
>> View
>>> Navigation Bar
>>>> Navigation Item - New Form
>> View
>>> Toolbar
>>>> Bar Button Item - Cancel
>>>> Bar Button Item - Flexible Space
>>>> Bar Button Item - Done
我的方法被调用在按下按钮:
IFDNewFormViewController.m:
- (void) newFormDisplay:(id)sender {
// Show the Create Flightlog View
IFDNewFormViewController *newForm = [[IFDNewFormViewController alloc] init];
newForm.flightlogDelegate = self;
newForm.dataType = [self ifdDataType];
newForm.displayDataType = [NSString stringWithFormat:@"New %@",[self displayDataType]];
newForm.title = [NSString stringWithFormat:@"Title %@",[self displayDataType]];
newForm.navigationItem.title = [NSString stringWithFormat:@"NavItem.Title %@",[self displayDataType]];
newForm.navigationController.title = [NSString stringWithFormat:@"NavController.Title %@",[self displayDataType]];
newForm.modalViewController.title = [NSString stringWithFormat:@"ModalViewController.Title %@",[self displayDataType]];
NSLog(@"iFDListViewController_Pad:newFormDisplay start form for dataType=%@ (%@)",[self ifdDataType], [self displayDataType]);
[self presentModalViewController:newForm animated:YES];
[newForm release];
}
我在厦门国际银行设置标题:
导航项目 - 新窗体 - >标题。
该标题是在视图上显示的标题。使用在这个论坛中找到的信息,我添加了以下几行:
newForm.navigationItem.title = [NSString stringWithFormat:@"NavItem.Title %@",[self displayDataType]];
newForm.navigationController.title = [NSString stringWithFormat:@"NavController.Title %@",[self displayDataType]];
newForm.modalViewController.title = [NSString stringWithFormat:@"ModalViewController.Title %@",[self displayDataType]];
仍然没有快乐。
我很想念这里的东西。有任何想法吗?
我已经添加了建议的代码。我需要在@property行中添加该类型。在分配了IFDNewFormViewController后,当我设置标题时,没有错误,但是xcode显示来自设置在.title =行结尾的断点“newFormNavBar(UINavigationBar *)0x0”。我在xib中验证了当在引用出口下单击View Controller - > Table View - > View - > Navigation Bar时:newFormNavBar < - 文件所有者。导航栏标题没有变化。仍读取xib中设置的“新窗体”。 – Kent 2011-06-16 17:27:29
我确实得到了这个工作,对@tlbrack提供的解决方案进行了一些更改。更改:1.我引用了UINavigationItem,2.移动了一行代码:'newFormNavItem。title = [NSString stringWithFormat:@“Title%@”,[self displayDataType]];'viewWillAppear:(BOOL)animated' in IFDNewFormViewController.m。为什么不是在'IFDNewFormViewController * newForm = [[IFDNewFormViewController] alloc] initWithNibName:@“whatever-the-file-name-is”bundle:nil];后调用了newFormNavItem?我应该在最终更改中添加解决方案,还是将@ tlbrack标记为解决方案? – Kent 2011-06-17 01:39:15