Setting the title of the navigation position in modal form

In a review of existing answers, I think Steve's question and answer to the code word are included in my kit. But I missed something.

My xib for modal view: 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

My method that is called when the button is clicked:

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];
}

I set the header to xib:

Navigation item - New form → title.

This title is displayed on the screen. Using the information found in this forum, I added the following lines:

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]];

Still no joy.

Something is missing for me. Any ideas?

+3
source share
1 answer

Since you are not pushing this view controller on the UINavigationController, setting newForm.navigationItem.title will not do the trick.

, modal view controller, . , , xib.

IFDNewFormViewController.h

    UINavigationBar *customNavBar;

    @property (nonatomic, retain) IBOutlet *UINavigationBar customNavBar;

IFDNewFormViewController.m:

    @synthesize customNavBar;

dealloc nil viewDidUnload.

xib , "New Referencing Outlet" customNavBar. , xib .

IFDNewFormViewController, :

    IFDNewFormViewController *newForm = [[IFDNewFormViewController] alloc] initWithNibName:@"whatever-the-file-name-is" bundle:nil];

xib .

+3

All Articles