在我的iPhone App中如下图所示,我实现了PopViewController
现在点击按钮点击(关闭)我想关闭弹出视图
我怎样才能做到这一点?
答案 0 :(得分:2)
试试这个:
if ([popoverController isPopoverVisible]) {
[popoverController dismissPopoverAnimated:YES];
}
添加@class ViewCntrollerClass2;
答案 1 :(得分:2)
您问题的简单答案是
if ([PopViewController isPopoverVisible]) {
[PopViewController dismissPopoverAnimated:YES];
}
然而,假设您使用外部按钮,有许多委托问题可以参与此问题我建议您参考这篇文章:Dismiss popover using UIbutton
答案 2 :(得分:1)
试试这个
in .h
@protocol popOverDismissDelgate
-(void)dismissPopOverView;
@end
@interface ///
@property(nonatomic,assign) <popOverDismissDelgate> delegate;
@end
in .m
@synthesize delegate;
并写
-(void)dismissPopOverView{
[PopViewController dismissPopoverAnimated:YES];
}
创建第二个视图控制器以创建弹出视图控制器时,将委托设置为自己
SecondView *sv=[[SecondView alloc]initWithNibName:];
sv.delegate=self;
在第二个视图控制器中实现此方法
-(IBAction)buttonTapped{
[(id)delegate performSelector:@selector(dismissPopOverView)];
}
Tis将关闭您的弹出视图