NewView 显示在 PopOver 中而不是 newView
我从 PopOver 中选择了正确的视图,但它没有显示在父视图中,而是显示在 PopOverView 中。
以下是一些屏幕截图:
在我选择反馈选项而不是在我的父视图中显示视图(在我的例子中是 SecondViewController (灰色背景屏幕))之后显示在 PopOver 本身中。
有关信息,我有三个 VC,即 FirstViewController、SecondViewController 和 ThirdViewController,每个都分配给每个 TabBar 项目。我想将 SecondViewController 作为 PopOver 的父级。
这是我在 AppDelegate.m 中创建 PopOver 的代码
- (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) )以便新视图显示在我的父视图中而不是弹出视图中。
谢谢
I have the right view selected from my PopOver but instead of showing in Parent View it is showing in PopOverView.
Here are some screenshots:
After I select the Feedback option instead showing the view in my parentview which in my case is SecondViewController (grey background screen) it is showing in the PopOver itself.
For information I have Three VC's namely FirstViewController, SecondViewController and ThirdViewController each assigned to each TabBar item. I want to make SecondViewController as parent for the PopOver.
Here is my code where I create PopOver in my 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];
}
}
And the code in my PopOverController.m where I am making a choice of which new view to show
- (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];
}
Can anyone let me know how I can make the reference to my parent view (SecondViewcontroller) so that the new view shows in my parent view rather than the popover view.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您插入到弹出窗口 UINavigationController 中,并在
didSelectRowAtIndexPath
中将新创建的控制器推送到现有堆栈(到弹出窗口 UINavigationController 中),但不推送到选项卡栏中。为了将新创建的控制器推送到第二个选项卡,您需要将第二个选项卡(现在是 SecondViewController)分配给新的 UINavigationController 并完全使用此导航堆栈。
代码如下所示:
You insert into popover UINavigationController and in
didSelectRowAtIndexPath
push newly created controller to existed stack (into popover UINavigationController), but not into tab bar.In order to push newly created controller to second tab you need to assign second tab (now it is SecondViewController) to new UINavigationController and use exactly this navigation stack.
Code will look like this: