uinavigationcontroller problem

Discussion in 'iOS Programming' started by sagarshivam, Sep 3, 2011.

  1. sagarshivam, Sep 3, 2011
    Last edited: Sep 3, 2011

    sagarshivam macrumors member

    May 24, 2011
    Dear All

    In my sample project for iPad, I am using uisplitviewcontroller and further , uinavigationcontroller in root view controller (left panel of split view pane) so that on tapping the disclosure button of main table, next view (uitableview) comes up.

    Logic is simple that I should push the object of next view class to navigation controller. But I dont understand where I am lacking.

    @synthesize window, splitViewController, rootViewController, detailViewController;
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
        UINavigationController *rootNav = [[UINavigationController alloc] initWithRootViewController:rootViewController];
    	splitViewController.viewControllers = [NSArray arrayWithObjects:rootNav,detailViewController,nil]; 
        splitViewController.delegate = detailViewController;
        [window addSubview:splitViewController.view];
        [window makeKeyAndVisible];
        [rootNav release];
        return YES;
    RootViewController.m is:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *CellIdentifier = @"CellIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
            cell.accessoryType = UITableViewCellAccessoryNone;
        cell.textLabel.text = [NSString stringWithFormat:@"Row %d", indexPath.row];
    	cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
        return cell;
    and didSelectRowAtIndexPath method (of RootViewController.m)is:

    - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    	    _nav= [[nextview alloc] initWithStyle:UITableViewStylePlain];
               // _nav is object of class nextview (uitableviewcontroller type)
    	    [self.navigationController pushViewController:_nav animated:YES];

    I am unable to understand that on tapping cell of root view controller, why nextview is not visible.
  2. dantastic macrumors 6502a


    Jan 21, 2011
  3. sagarshivam thread starter macrumors member

    May 24, 2011
    Sorry for incomplete query. I just updated my query and code
  4. ArtOfWarfare macrumors G3


    Nov 26, 2007
    In the code you showed us, _nav isn't declared anywhere. I believe you want it to be a pointer to a UITableView... did you declare it as such in your header file, perchance? It's also possible that the _ character does something special that I'm simply not aware of.

    Also, you have "nextview". Is that a custom class? You haven't shown us your .h and .m for it.
  5. sagarshivam thread starter macrumors member

    May 24, 2011
    _nav is declared properly. And nextview class is a standard UItableviewcontroller type.

    When I am using the same way of pushing the other uitableviewcontroller class object (in my case it is _nav) in root viewcontroller without using uisplitviewcontroller, everything works fine.

    Any suggestions?
  6. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    You should probably follow standard naming conventions and rename your nextview class using "camel-case" (i.e. something like NextTableViewController. It will make things less confusing to those trying to help (or those having to maintain your code in the future).
  7. sagarshivam thread starter macrumors member

    May 24, 2011
    Thanks all

    I was making some mistakes in delegate class. Its working fine now. Thanks for all the support and sugegstion

Share This Page