[英]How to dismiss a popover with a navigation controller?
I have an app which is divided in four views, when I tap a view the app shows a popover and that popover has a navigation controller. 我有一个分为四个视图的应用程序,当我点击一个视图时,该应用程序将显示一个弹出窗口,并且该弹出窗口具有导航控制器。 I can navigate between view and the data is shows correctly.
我可以在视图之间导航,并且数据可以正确显示。 But when I am in the last view and I tap a row, the popover don't dismiss (I want in didSelectRowAtIndexPath).
但是,当我在最后一个视图中并点击一行时,弹出菜单不会消失(我想要在didSelectRowAtIndexPath中)。
How could do it? 怎么办
I tried in this way, I created a method that dismiss the popover and I call this method en didSelectRowAtIndexPath, but did not works. 我以这种方式尝试过,我创建了一个消除弹出窗口的方法,并且将该方法称为didSelectRowAtIndexPath,但没有用。
This is the method in the main ViewController 这是主ViewController中的方法
-(IBAction)mostrarTabla:(id)sender
{
// Popover that shows the table
UIPopoverController *popover;
// RootViewController is the first view
RootViewController *rootViewController = [[RootViewController alloc] init];
// With a nav bar
UINavigationController *navBar = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[rootViewController release];
// Popover customitation
navBar.contentSizeForViewInPopover = CGSizeMake(20.0f, 20.0f);
popover = [[UIPopoverController alloc] initWithContentViewController:navBar];
[navBar release];
popover.delegate = self;
popover.popoverContentSize = CGSizeMake(320.0f, 832.0f);
// PopOver is shows in the view 1
[popover presentPopoverFromRect:CGRectMake(100.0f, 10.0f, 20.0f, 20.0f) inView:_view1 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
I create a method in this View Controller 我在此View Controller中创建一个方法
-(void)hidePopover
{
[self.popOver dismissPopoverAnimated:YES];
}
And in the last view I used the method but did not works 在最后一个视图中,我使用了该方法,但是没有用
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ViewController *grafica = [[ViewController alloc] init];
self.indicadorId = [[self.arrayId objectAtIndex:indexPath.row] integerValue];
DataIndicador *datos =[[DataIndicador alloc] init];
datos.idIndicador = self.indicadorId;
[datos release];
[grafica hidePopover];
}
In the last view I want that the popover returns to its view and shows the data (a chart) 在最后一个视图中,我希望弹出窗口返回其视图并显示数据(图表)
Thanks 谢谢
ViewController的grafica瞬间与最初显示弹出窗口的VieController的瞬间不一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.