简体   繁体   English

如何直接移动到在第三个选项卡iPhone中作为子视图添加的视图

[英]How to directly move to a view which is added as subview in in third tab iPhone

First of all sorry for the title.Actually i dont know how to give a appropriate title for this scenario. 首先,对标题感到抱歉。实际上,我不知道如何为这种情况提供适当的标题。

I have a login view.Once the authentication is success next view is a tab bar view with four tabs.I created this as follows: 我有一个登录视图。一旦身份验证成功,下一个视图是带有四个选项卡的选项卡栏视图。

UIViewController *firstTab = [[SAHomeView_iPad alloc]initWithNibName:@"SAHomeview_iPad" bundle:nil];
         firstTab.tabBarItem.image = [UIImage imageNamed:@"Home.png"];
         UIViewController *secondTab = [[SAMenuView_iPad alloc]initWithNibName:@"SAMenuView_iPad" bundle:nil];
         secondTab.tabBarItem.image = [UIImage imageNamed:@"Menu.png"];
         UIViewController *thirdTab = [[SAGraphView_iPad alloc]initWithNibName:@"SAGraphView_iPad" bundle:nil];
         thirdTab.tabBarItem.image = [UIImage imageNamed:@"Graph.png"];
         UIViewController *fourthTab = [[SAAboutView_iPad alloc]initWithNibName:@"SAAboutView_iPad" bundle:nil];
         fourthTab.tabBarItem.image = [UIImage imageNamed:@"info.png"];
         UITabBarController *tabBarController = [[UITabBarController alloc] init];
         tabBarController.viewControllers = [NSArray arrayWithObjects:firstTab, secondTab,thirdTab,fourthTab, nil];
         SAAppDelegate *delegate = [UIApplication sharedApplication].delegate;
         delegate.window.rootViewController = tabBarController;

Now in the third tab,i have added a calendar button,which when pressed will give a calendar view.i added this calendar view as subview in third tab. 现在,在第三个选项卡中,我添加了一个日历按钮,按下该按钮将提供一个日历视图。我在第三个选项卡中将该日历视图添加为子视图。

Now once the user is logged in,there will be a calendar button in the home tab. 现在,一旦用户登录,主页选项卡中将出现一个日历按钮。 Once user tap the calendar button he should move to the calendar view. 用户点击日历按钮后,他应该移至日历视图。 This calendar view is actually added as a subview in the third tab. 该日历视图实际上是作为子视图添加到第三个选项卡中的。

Can anyone please help me to solve this scenario. 谁能帮我解决这种情况。 Many thanks in advance. 提前谢谢了。 登录

登录成功后查看日历视图(在第三个选项卡中作为子视图添加)

I suggest that you take the calendar view out of your thirdTab view hierarchy and assign it to it's own custom viewController, so that it can be presented with equal status from any other viewController in your app. 我建议您将日历视图从thirdTab视图层次结构中取出,并将其分配给它自己的自定义viewController,以便可以与您应用程序中的任何其他viewController相同的状态显示日历视图。

You can then invoke the calendar using a modal storyboard segue or in code using: 然后,您可以使用模式情节提要板segue或使用以下代码在日历中调用日历:

[self presentViewController:calendarViewController animation:YES completion:NIL];

and dismiss it: 并关闭它:

[self.presentingViewController dismissModalViewControllerAnimated:YES];

When you present it, you will lose your tab controller context, as the expectation is that you will return to the view that presented it. 呈现它时,您将失去标签控制器上下文,因为期望您将返回到呈现它的视图。 When you dismiss it, you get that presenting view back with the tab bar context. 当您关闭它时,您将获得带有标签栏上下文的演示视图。

Friends finally i did it in this way.Thanks for all your help.Hope this help you also.:) 朋友们终于以这种方式做到了。谢谢你的帮助。希望也能帮到你。

- (IBAction)moveToCalendar:(id)sender {
    self.tabBarController.delegate = self;
    self.tabBarController.selectedIndex = 2;
    [(SAGraphView_iPad *)self.tabBarController.selectedViewController calendar:self];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM