2012-04-10 9 views
0

Ich habe den folgenden Code:Problem mit Drücken auf Navigationsleiste

- (void)setupBook 
{ 
    if (self.bookNavigationController) { 
     BookViewController *bookVC = [[BookViewController alloc] initWithTemplate:x]; 
     self.myBookVC = bookVC; 
     [bookVC release];  
     myBookVC.pageTitle = @"My Book"; 
     UINavigationController *nController = [[UINavigationController alloc] initWithRootViewController:myBookVC]; 
     self.bookNavigationController = nController; 
     [nController release]; 
    } 
} 

und dann in den anderen Teilen des Codes ich habe:

[self.someOtherNavigationController pushViewController:self.bookVC]; 

aber jetzt, wenn ich versuche selbst zu präsentieren. bookNavigationController als Modal View-Controller, ist es wie der myBookVC nicht da ist. warum ist das? Es erscheint nur eine leere Ansicht mit einer Navigationsleiste.

Antwort

0

Wenn Sie Ihren View-Controller zuerst erstellen, weisen Sie ihn einer Eigenschaft zu. Wenn Sie ihn jedoch als rootViewController des Nav-Controllers zuweisen, verweisen Sie auf einen ivar. Verwenden Sie stattdessen die Eigenschaft, wenn Sie den RootViewController zuweisen.

BookViewController *bookVC = [[BookViewController alloc] initWithTemplate:x]; 
bookVC.pageTitle = @"My Book"; 
self.myBookVC = bookVC; 
[bookVC release]; 
UINavigationController *nController = [[UINavigationController alloc] initWithRootViewController:self.myBookVC]; 
self.bookNavigationController = nController; 
[nController release]; 
+0

tat das und half auch nicht – xonegirlz

Verwandte Themen