使用按钮关闭弹出窗口(在另一个 .xib 文件中)
我的视野中有一个弹出窗口。在此弹出窗口中包含来自另一个 xib 文件 (Infoscreen.xib) 的内容。如何使用另一个 .xib 文件内的按钮关闭弹出窗口?这是我的代码的片段:
-(IBAction)infoDruk: (id)sender {
if([popover isPopoverVisible]) {
[popover dismissPopoverAnimated:YES];
}
else {
Infoscreen *choser = [[Infoscreen alloc] init];
popover = [[UIPopoverController alloc]
initWithContentViewController:choser];
[choser release];
popover.delegate = self;
popover.popoverContentSize = CGSizeMake(230, 563);
[popover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
}
非常感谢帮助!
I've got a popover within my view. Within this popover there is content from another xib file (Infoscreen.xib). How can I dismiss the popover with a button which is inside another .xib file? Here's a snippit of my code:
-(IBAction)infoDruk: (id)sender {
if([popover isPopoverVisible]) {
[popover dismissPopoverAnimated:YES];
}
else {
Infoscreen *choser = [[Infoscreen alloc] init];
popover = [[UIPopoverController alloc]
initWithContentViewController:choser];
[choser release];
popover.delegate = self;
popover.popoverContentSize = CGSizeMake(230, 563);
[popover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
}
Help is greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的另一个 xib 应该通知(回电)您的弹出窗口,该按钮已被按下。这个概念称为代表。因此,您可以在此回调方法中关闭弹出窗口。
Your another xib should inform (give a call back) to your pop over that such button has been pressed. This concept is called delegates. Thus, you can dismiss the pop over in this call back method.