我有一个根视图控制器,我在其中加载包含三个按钮的子视图。当我触摸其中一个时,会显示一个弹出窗口。弹出窗口包含一个图像视图和一个带有完成按钮的栏。我想在触摸完成按钮时忽略此弹出窗口。为此,我使用此代码
- (IBAction)btnDone:(UIBarButtonItem *)sender {
[self.view removeFromSuperview];
[APPDELEGATE.parkDetail. popoverController dismissPopoverAnimated:YES];
// [APPDELEGATE.parkDetail.popoverController dismissPopoverAnimated:YES ];
}
并且popover就像这样显示
- (IBAction)btnParkMap:(id)sender {
[popoverController dismissPopoverAnimated:YES];
if ([popoverController isPopoverVisible]) {
[popoverController dismissPopoverAnimated:YES];
} else {
parkMap * v = [[parkMap alloc]initWithNibName:@"parkMap" bundle:nil];
v.contentSizeForViewInPopover = CGSizeMake(350, 300);
popoverController = [[UIPopoverController alloc] initWithContentViewController:v];
CGRect popRect = CGRectMake(self.btnShowPopover.frame.origin.x+330,
self.btnShowPopover.frame.origin.y+170,
self.btnShowPopover.frame.size.width,
self.btnShowPopover.frame.size.height);
[popoverController presentPopoverFromRect:popRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
}
答案 0 :(得分:3)
试试此代码
[self dismissViewControllerAnimated:YES completion:nil];
或尝试@ nirav's和
答案 1 :(得分:1)
尝试编写以下代码
[yourPopOverobject dismissPopoverAnimated:YES];
让我知道它是否有效..
快乐编码!!!!!
答案 2 :(得分:1)
PopUpOver可以关闭UIWebView的默认上下文菜单。这很简单,因为我们只需要为网页的body元素将CSS属性“-webkit-touch-callout”设置为“none”。我们可以在UIWebView委托方法“webViewDidFinishLoad:”中使用JavaScript来实现这一点......
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
}
答案 3 :(得分:0)
- (IBAction)btnDone:(UIBarButtonItem *)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
答案 4 :(得分:0)
尝试检查以下代码......
if ([popoverobject isPopoverVisible]) {
[popoverobject dismissPopoverAnimated:YES];
[popoverobject release];
}
}
#pragma mark -
#pragma mark UIPopoverController delegate
-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
//if (popoverController == popoverobject) {
[popoverobject release];
// }
}
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
NSLog(@\"popover about to be dismissed\");
return YES;
}
告诉我工作与否......