Question

I'm seem unable to get any kind of communication going between my Main View Controller and a Table View Controller which is being displayed inside a Popover View (iPad).

I'm setting up the Table View inside a Navigation Controller in the usual way:

// create popover
    if (self.popoverController == nil) {

    filesViewController = [[[MyTableViewController alloc] initWithFiles:fileList] autorelease];

    UINavigationController *navCtrl = [[[UINavigationController alloc] initWithRootViewController:filesViewController] autorelease];

    self.popoverController = [[UIPopoverController alloc] initWithContentViewController:navCtrl];

        self.popoverController.delegate = self;

        // resize popover
        self.popoverController.popoverContentSize = CGSizeMake(320.0, 44 + [fileList count] * 44);
    }

Everything is working fine, and I'm passing an array of file names (fileList) into the Table View, which is held in the Table View as an array called listOfFiles. The Table View displays the filenames, and when one is selected by the user I want to pass that filename back to the Main View Controller. However, I cannot get any communication going back from the Table View's didSelectRowAtIndexPath method to the Main VC. I've tried all sorts of outlets going in various directions, and I've tried creating a new object in didSelectRowAtIndexPath to handle the filename coming from the Table View. I can pass the filename out to the new object, but when I try to send that into the Main VC it is null again. Everything I send to my Main VC while that popover is active comes up as null.

    - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {

    NSLog(@"%@", handler.addressForImageFile);

    self.popoverController = nil;
    [self.popoverController release];
}

Is there some reason why my Main VC won't get anything but null objects from my Table View? I've spent days trying so many different things. I feel like there's some fundamental gap in my knowledge of how popovers work. Surely there is a simple way to send a string back to my Main VC when it is selected from the Table View?

Thanks so much for any help!

Was it helpful?

Solution

There's propably a much better way to do this, but depending on the goal of passing the string, one way could be to use NSUserDefaults.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top