在模式视图中设置导航项标题
|
在审查现有答案时,我认为史蒂夫(Steve)的问题和代号(codelark)的答案是我问题的壁橱。但我在这里缺少一些东西。
我的模态视图的xib:
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];
}
我在xib中设置了标题:
导航项-新表单->标题。
该标题就是视图上显示的标题。使用此论坛中的信息,我添加了以下几行:
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]];
仍然没有喜悦。
我在这里错过了一些东西。有任何想法吗?
没有找到相关结果
已邀请:
1 个回复
埃庐
和奥特莱斯物业
在IFDNewFormViewController.m中:
确保在dealloc中释放它,并在viewDidUnload中将其设置为nil。 编辑Xib时,右键单击导航栏,然后单击“新引用出口”旁边的空心圆并将其拖动到文件所有者,然后选择customNavBar。这样,属性将在加载后包含来自您的xib的条。 初始化IFDNewFormViewController时,请确保使用以下内容:
否则,甚至无法使用xib中的数据。