我有一个包含多个弹出窗口的页面,当我出现另一个弹出窗口时,我试图解散我正在使用以下代码,但它似乎没有解除弹出窗口
-(IBAction)OISButton:(id)sender{
if(![popoverController isPopoverVisible]){
OISView *oisView = [[OISView alloc] init];
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:oisView];
[pop setDelegate:self];
[pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[pop setPopoverContentSize:CGSizeMake(320, 460)];
[oisView release];
}
else{
// close popover
[popoverController dismissPopoverAnimated:YES];
}
}
有关如何修改此代码的任何建议?感谢
答案 0 :(得分:2)
您没有分配给popoverController
,这可能会解释您遇到的问题。
答案 1 :(得分:1)
感谢Tom让我朝着正确的方向前进,我已经将下面的代码包含在一个名为OISView的视图中,其格式为处理多个popovers:
-(IBAction)OISButton:(id)sender{
if([popoverController isPopoverVisible]){
[popoverController dismissPopoverAnimated:YES];
} else
{
OISView *oisView = [[OISView alloc] init];
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:oisView];
self.popoverController = pop;
[pop setDelegate:self];
[pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[pop setPopoverContentSize:CGSizeMake(320, 460)];
[oisView release];
}
}