开发者

how to dismiss an existing popover and show another popover in a single touch in ipad

i'm having a UItableView with开发者_如何学C lot of cells. Each cell is associated with different kind of popovers. When i touch a cell a popover will be shown. When i touch the other cell of the tableview i want to dismiss the existing popover and i've to show the popover corresponding to the selected cell.

But, when i touch the area outside the popover, the existing popover gets dismissed but i couldn't retrieve the cell index i've selected. Is there any way to dismiss an existing popover and show another popover in a single touch in ipad?


Solved the Problem

I've got the solution by setting passthroughView of the popover as the tableview in which i want to display the popover.


I had a similar problem, but I couldn't use passthroughView because I wanted my new popover be over the old one. So I used setContentViewController method.

I have a SplitViewController, that shows SettingsViewController in a popoverController and it can show a LoginViewController in the same popover, when user clicks a button in SettingsViewController.

This method is located in SplitViewController:

- (void)showLoginViewController
{
  if ( ! _myPopoverController.isPopoverVisible) {
    _myPopoverController = [[UIPopoverController alloc] initWithContentViewController:self.loginViewController];
    [_myPopoverController presentPopoverFromRect:popoverOriginRect inView:self.view permittedArrowDirections:0 animated:YES];
  }
  else {
    [_myPopoverController setContentViewController:self.loginViewController animated:YES];
  }
}

I have a property in a SplitViewController:

@property (nonatomic, strong) UIPopoverController *myPopoverController;

It is essential not to create a new instance of _myPopoverController but to set ContentViewController in old instance. It is a good practice to store PopoverController in a strong property, since it must not be deallocated while visible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜