我从我的PopOver中选择了正确的视图,但不是在父视图中显示,而是在PopOverView中显示。NewView显示PopOver而不是newView
下面是一些截图:
我选择而不是显示它在酥料饼本身显示我parentview认为这在我的情况是SecondViewController(灰色背景画面)反馈选项之后。
的信息,我有三个VC的即FirstViewController,SecondViewController和ThirdViewController每个分配给每个的TabBar项目。我想让SecondViewController作为PopOver的父项。
这里是我的代码,我在我的AppDelegate.m
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if([viewController isKindOfClass:[SecondViewController class]]){
NSInteger index = [[self tabBarController] selectedIndex];
CGRect buttonFrame = [[[[[self tabBarController] tabBar] subviews] objectAtIndex:index+1] frame];
PopOverViewController *popoverContentController = [[PopOverViewController alloc]init];
UINavigationController *navcon = [[UINavigationController alloc]initWithRootViewController:popoverContentController];
popoverContentController.contentSizeForViewInPopover = CGSizeMake(250, 85);
popover = [[UIPopoverController alloc]initWithContentViewController:navcon];
NSLog(@"X:%f Y:%f",buttonFrame.origin.x,buttonFrame.origin.y);
[popover presentPopoverFromRect:buttonFrame inView:self.tabBarController.tabBar permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
}
创建酥料饼而在我PopOverController.m的代码,我想提出一个选择其中的新观点,以显示
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
sendFeedback *sendEmailViewController = [[sendFeedback alloc]initWithNibName:@"sendFeedback" bundle:nil];
downLoad *downloadFilelViewController = [[downLoad alloc]initWithNibName:@"downLoad" bundle:nil];
if (indexPath.row == 0)
[self.navigationController pushViewController:sendEmailViewController animated:YES];
else
[self.navigationController pushViewController:downloadFilelViewController animated:YES];
}
任何人都可以让我知道如何使我的父视图(SecondViewcontroller)的引用,使新视图显示在我的父视图,而不是弹出视图。
感谢
我跟着你的代码,我收到此错误“未知的接收器” tabBarController。所以我需要在PopOverController.h文件中再次创建tabBarController,否则我已经将AppDelegate.h文件导入PopOverController.m文件,但仍然是相同的错误。你可以详细说一下这个 – 125369 2012-02-08 13:48:56
没有必要创建新的tabBar,你已经拥有它了。使用已存在.. – beryllium 2012-02-08 14:07:47
我通过使用现有的tabBarController来做同样的事情,但得到与上面一样的错误。顺便说一句,我添加了您在我的PopOverViewController.m文件中didSelectRowAtIndexPath方法下建议的代码。这应该是正确的。但同样的错误。请让我摆脱这一点。 – 125369 2012-02-08 14:18:48