Using Popover View to Change "Parent" View?

Discussion in 'iOS Programming' started by hotwire132002, May 2, 2010.

  1. hotwire132002 macrumors 65816

    hotwire132002

    Joined:
    Jan 24, 2004
    Location:
    Cadillac, MI
    #1
    I'm working on my first iPad app that utilizes a popover view, and I'm trying to figure out how to update the "parent" view once an item is selected from the popover.

    Right now, the popover view is called as follows (from within FeedsDetailViewController.m):

    Code:
    FeedsViewController* content = [[FeedsViewController alloc]  initWithTitle:@"Title" withNavigationTitle:@"NavTitle" withPropertyFile:propFile withNavType:@"popover"];
    		UIPopoverController* aPopover = [[UIPopoverController alloc]
    										 initWithContentViewController:content];
    		
    		aPopover.delegate = self;
    		[content release];
    		
    		
    		// Store the popover in a custom property for later use.
    		self.popoverController = aPopover;
    		[aPopover release];
    		
    	
    		[self.popoverController presentPopoverFromBarButtonItem:sender
    									   permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    		}
    
    This particular view is also used in a Split View as the main navigation controller. When it's used as the navigation controller in the SplitView, the following code is called to update the "detail" portion of the SplitView (from within FeedsViewController.m):

    Code:
    UISplitViewController *split = (UISplitViewController *)self.navigationController.parentViewController;
    					UINavigationController *nav = [split.viewControllers objectAtIndex:1];
    					FeedsDetailViewController *detail = [nav.viewControllers objectAtIndex:0];
    					
    					// Push in the new article
    					FeedsDetailViewController *fdvController = [[FeedsDetailViewController alloc] initWithDictionary:itemDictionary withPropertyFile:passPropFile];
    					
    					[detail.navigationController pushViewController:fdvController animated:YES];
    						[fdvController release];
    
    That code works fine in the split view, but I can't figure out how to update the "detail" view controller (FeedsDetailViewController) from the popover. Addressing self.navigationController.parentViewController doesn't do any good; is there a different "parent" view I might need to push the new FeedsDetailViewController into?

    Thanks in advance for any help you can provide....
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Have you looked at the code for a simple Split-View Based app template? It pretty much does almost all you're asking for.
     
  3. hotwire132002 thread starter macrumors 65816

    hotwire132002

    Joined:
    Jan 24, 2004
    Location:
    Cadillac, MI
    #3
    You mean Apple's MultipleDetailViews example? I have looked at that; I'll look it over more closely tomorrow though ;-)
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    No, I mean create a new project using the Split-View Based template. The basic project it creates has code that updates the detail view when selections are made from the root view, whether it's the left-side of a landscape split view or the popover of a portrait mode. But maybe I'm not understanding what exactly it is that you're asking.
     

Share This Page