Search code examples
iosobjective-cuinavigationcontrolleruisplitviewcontroller

Master detail uisplitViewController and UINavigationController view


I try to push from a detail view to an other view. I have a tableView in a detailView "ConRDPDetailViewController" and I will like that when I click on a row, that push the new view "BookmarkEditorController". here is my method in "ConRDPDetailViewController" where I try to do that :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
        {
                ComputerBookmark* bookmark = nil;
            if([indexPath section] == SECTION_BOOKMARKS)
            {
                    // first row has either quick connect or add bookmark item
                    if([indexPath row] == 0)
                    {

                   // show add bookmark controller: is there I try to push the new View
                     BookmarkEditorController* bookmarkEditorController = [[[BookmarkEditorController alloc] initWithBookmark:[[ComputerBookmark alloc] initWithBaseDefaultParameters]] autorelease];
                     [bookmarkEditorController setTitle:NSLocalizedString(@"Ajouter Connexion", @"Add Connection title")];
                        UINavigationController *view = [[UINavigationController alloc] initWithRootViewController:bookmarkEditorController];

                     [view.navigationController pushViewController:bookmarkEditorController animated:YES];
                     [bookmarkEditorController setDelegate:self];

                    [bookmarkEditorController setHidesBottomBarWhenPushed:YES];



                     }


            }
    }

But nothing is happen, here is my method didFinishLaunchingWithOptions in AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self redirectConsoleLogToDocumentFolder];




    // Initialize the app window
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    AuthentificationViewController *authentificationViewController =[[AuthentificationViewController alloc] initWithNibName:@"AuthentificationView" bundle:nil];
    //self.window.rootViewController = self.splitViewController;
    self.window.rootViewController = authentificationViewController;
       [self.window makeKeyAndVisible];

    // The new popover look for split views was added in iOS 5.1.
    // This checks if the setting to enable it is available and
    // sets it to YES if so.
    // if ([self.splitViewController respondsToSelector:@selector(setPresentsWithGesture:)])
    // [self.splitViewController setPresentsWithGesture:YES];


    return YES;
}

Thank you in advance


Solution

  • You need to embed the table view controller in a navigation controller.

    Then you can push the detail view with this code:

    BookmarkEditorController* bookmarkEditorController = [[[BookmarkEditorController alloc] initWithBookmark:[[ComputerBookmark alloc] initWithBaseDefaultParameters]] autorelease];
    [bookmarkEditorController setTitle:NSLocalizedString(@"Ajouter Connexion", @"Add Connection title")];
    [self.navigationController pushViewController:bookmarkEditorController animated:YES];
    [bookmarkEditorController setDelegate:self];
    [bookmarkEditorController setHidesBottomBarWhenPushed:YES];