我从我的ViewController.m
中调用它当我从弹出窗口中选择一行时,我试图调用下面的控制器
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
...
TSPopoverController *dismiss = [[TSPopoverController alloc]init];
[dismiss dismissPopoverAnimatd:YES];
}
在课堂上找到:TSPopoverController.m
- (void) dismissPopoverAnimatd:(BOOL)animated
{
if (self.view) {
if(animated) {
[UIView animateWithDuration:0.2
delay:0.0
options:UIViewAnimationOptionAllowAnimatedContent
animations:^{
popoverView.alpha = 0;
}
completion:^(BOOL finished) {
[self.contentViewController viewDidDisappear:animated];
popoverView=nil;
[self.view removeFromSuperview];
self.contentViewController = nil;
self.titleText = nil;
self.titleColor = nil;
self.titleFont = nil;
}
];
}else{
[self.contentViewController viewDidDisappear:animated];
popoverView=nil;
[self.view removeFromSuperview];
self.contentViewController = nil;
self.titleText = nil;
self.titleColor = nil;
self.titleFont = nil;
}
}
}
当我尝试调用该方法时:
- (void) dismissPopoverAnimatd:(BOOL)animated
什么都没发生。当我在popovertable中做出选择时,有人能指出我如何让这个popOverView消失的正确方向吗?
答案 0 :(得分:1)
我认为问题是你在didSelectRowAtIndexPath方法中再次实例化popover。相反,你应该创建一个成员并使用它来解雇。请参阅此answer。
答案 1 :(得分:0)
我通过添加:
解决了这个问题@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>
{
TSPopoverController *popoverController;
}
然后我在下面的函数中调用了它:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
...
[popoverController dismissPopoverAnimatd:YES];
}
感谢您指导我正确的方向@xoail!