开发者

Getting a reference to the UIPopover that pops up in the context of a UISplitViewController in iPad Landscape

开发者 https://www.devze.com 2023-03-06 17:02 出处:网络
This is a follow up question to Dismissing a UIpopover regarding how to dismiss a popover. I have a similar situation but its a UIPopover in the context of a Master Detail iPad application. I basical

This is a follow up question to Dismissing a UIpopover regarding how to dismiss a popover.

I have a similar situation but its a UIPopover in the context of a Master Detail iPad application. I basically create TWO Navigation Controllers (this is off a recommendation from CS193P), one for the Master and one for the Detail.

in my AppDelegate, I have the following to set up my UISplitViewController

#pragma 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Creating the EpisodesViewController (used on both iPhone and iPad)
EpisodesViewController *navControllerRootController = [[EpisodesViewController alloc] init];
UINavigationController *masterNav = [[UINavigationController alloc]initWithRootViewController:navControllerRootController];
[navControllerRootController release];
masterNav.tit开发者_运维问答le=@"Episodes";

if ([self iPad]) {
    EpisodeDetailViewController *detailViewController = [[EpisodeDetailViewController alloc]init];
    UINavigationController *detailNav = [[UINavigationController alloc]initWithRootViewController:detailViewController];
    detailNav.navigationBar.tintColor = [UIColor blackColor];

    self.splitviewController = [[UISplitViewController alloc] init];
    self.splitviewController.delegate=detailViewController;
    self.splitviewController.viewControllers = [NSArray arrayWithObjects:masterNav,detailNav,nil];
    [window setRootViewController:self.splitviewController];

    [detailViewController release];
    [detailNav release];
}else {
    [window setRootViewController:masterNav];
} 
[masterNav release];
[self.window makeKeyAndVisible];
return YES;
}

So. the question is... how do i get a reference to the UIPopover that appears when I click the "Episodes" button. What I'd like to do is implement the solution from that other thread, but I dont have a reference (that I know of) to my popover so I can dismiss it.

[Edit] made the way that I created the detailNav the same as the way I created masterNav to avoid clouding the main issue.


Okay, I've got it.

I used a combination of the notification approach described here Dismissing a UIpopover .. I post th notification from the

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

in my Master view and I have an instance variable pointing to the UIPopover as described here

UISplitViewController in portrait: how to hide master popover programatically? which I use to actually dismiss the popover.

Works like a charm.

:-)

0

精彩评论

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