Question

In my current project, targeted for iOS 5.0 and up, I want to show a view with some buttons that let the user choose a layout for what is currently being drawn on the screen.

On iPhone & iPod Touch I let the choice view controller take over the entire screen by calling:

[self presentViewController:choiceController animated:YES completion:nil];

On iPad I show the same view controller's views in a popover by calling this:

    [self setChooseLayoutPopover:[[UIPopoverController alloc] initWithContentViewController:choiceController]];
    [[self chooseLayoutPopover] setDelegate:self];
    [[self chooseLayoutPopover] setPopoverContentSize:CGSizeMake(320.0, 460.0)];        
    [[self chooseLayoutPopover] presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

In both cases I pass two dismiss blocks to the choice view controller, one for when a layout is actually chosen, and one for when the user cancels the operation. On iPad touching outside the bounds of the popover does indeed cancel it, on iPhone & iPod Touch I show a Cancel-button that also works.

On iPhone & iPod Touch my dismiss block for making a choice works by calling:

[[self presentingViewController] dismissViewControllerAnimated:YES completion:[self dismissBlockDone]];

but on iPad presentingViewController is always nil, and even if I pass a pointer to my presenting view controller myself using the above call does nothing on iPad.

I did implement -(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController and set the presenting view controller as the delegate for the popover, and this method does get called when the user touches outside the popover, but I can not find what to call after the user actually touched a choice button. I can set the chosen value but I don't know how to get out of the popover afterwards.

Any suggestions?

Was it helpful?

Solution

Shouldn't you call something like:

   [popoverController dismissPopoverAnimated:YES];

to dismiss the popover? Or am I not understanding something?

OTHER TIPS

Call

[popoverController dismissPopoverAnimated:NO];

hope this helps!

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