C#的JSON库[关闭](JSON library for C# [closed])
Microsoft提供任何库在C#中使用JSON? 如果没有,你推荐什么开放源码库?
Does Microsoft provide any library to work with JSON in C#? If not, what open source library do you recommend?
原文:https://stackoverflow.com/questions/1474377
最满意答案
-viewWillDisappear:方法不是修改navigationController的视图控制器堆栈的最佳位置,因为它在切换选项卡和在其上按下视图时都会触发。
我玩了一下这个,发现最好的地方是 - [UITabBarControllerDelegate tabBarController:didSelectViewController:]方法。 所以,首先你需要指定一个对象作为标签栏的委托(我使用了app委托)。 将UITabBarController的delegate属性绑定到在代码或Interface Builder中实现UITabBarControllerDelegate协议的对象。
然后,实现-tabBarController:didSelectViewController:方法。 现在的诀窍是如何判断何时切换到“地址簿”选项卡。 我使用UINavigationController类型的属性(选项卡的根视图控制器)跟踪相关选项卡的视图控制器。 使用Interface Builder将tab1NavController属性绑定到实际实例后,可以使用它与viewController参数进行比较,以查看刚刚选择的选项卡。
@interface Pop2RootTabSwitchAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> { UINavigationController *tab1NavController; } @property (nonatomic, retain) IBOutlet UINavigationController *tab1NavController; @end @implementation Pop2RootTabSwitchAppDelegate - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { NSLog(@"[%@ tabBarController:%@ didSelectViewController:%@]", [self class], tabBarController, viewController); if (viewController == tab1NavController) { NSLog(@"viewController == tab1NavController"); [tab1NavController popToRootViewControllerAnimated:NO]; } }
The -viewWillDisappear: method is not the best place for modifying the view controller stack for your navigationController because it is triggered both when you switch tabs and when a view is pushed on top of it.
I played around with this a bit and found that the best place for this is in the -[UITabBarControllerDelegate tabBarController:didSelectViewController:] method. So, first you need to designate an object to be the delegate for your tab bar (I used the app delegate). Bind the delegate property of your UITabBarController to an object implementing the UITabBarControllerDelegate protocol in code or in Interface Builder.
Then, implement the -tabBarController:didSelectViewController: method. The trick now is how to tell when your "address book" tab is being switched to. I kept track of the view controller for the tab in question using a property of type UINavigationController (the root view controller for the tab). After binding the tab1NavController property to the actual instance using Interface Builder, it can be used to compare to the viewController parameter to see what tab was just selected.
@interface Pop2RootTabSwitchAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> { UINavigationController *tab1NavController; } @property (nonatomic, retain) IBOutlet UINavigationController *tab1NavController; @end @implementation Pop2RootTabSwitchAppDelegate - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { NSLog(@"[%@ tabBarController:%@ didSelectViewController:%@]", [self class], tabBarController, viewController); if (viewController == tab1NavController) { NSLog(@"viewController == tab1NavController"); [tab1NavController popToRootViewControllerAnimated:NO]; } }
相关问答
更多-
如何正确使用导航控制器来实现标签栏控制器(How to implement tab bar controller with navigation controller in right way)[2023-12-24]
嗨,你需要嵌入在它自己的导航控制器中的标签栏内的每个视图控制器。 所以流程就像这样(HomeVC嵌入在它自己的NavController中): / --> `NavController` --> `ViewController1` | --> `NavController` --> `ViewController2` `HomeViewContr ... -
导航控制器内的标签栏控制器,或共享导航根视图(Tab bar controller inside a navigation controller, or sharing a navigation root view)[2023-08-20]
以前的两个答案是正确的 - 我不使用UITabBarController在Tweetie。 编写一个自定义的XXTabBarController ( UIViewController简单子类)很容易被推入导航控制器堆栈,但仍然以“视图控制器”的理念生活很容易。 特定于帐户的视图( Tweets / Replies / Messages )上的每个“标签”都是自己的视图控制器,就他们而言,他们正在屏幕上被一个普通的UITabBarController交换。 The two previous answers g ... -
设置根视图控制器swift时删除新创建的导航栏(remove newly created navigation bar when setting root view controller swift)[2022-12-28]
您只需要隐藏任何一个导航栏。 nav!.navigationBarHidden = true You just need to hide any one of the navigation bar . nav!.navigationBarHidden = true -
要用TabBarController替换NavigationController : 在Storyboard中选择NavigationController 。 点击删除键。 选择ViewController 。 从菜单中选择Editor-> Embed in-> Tab Bar Controller 。 选择TabBarController并在Attributes Inspector中选中Is Initial View Controller 。 To replace the NavigationContro ...
-
导航控制器与导航控制器的标签栏控制器(Navigation controller with tab bar controller of navigation controller)[2022-03-05]
你可以在根控制器或者任何适合你的孩子上做navigationController.navigationBarHidden = true 。 但是,如果仅使用一个UINavigationController ,并且仅使用UITabBarController IMO navigationController ,则效果会更好。 If you don't want navigation bar of first navigation controller then from the interface builde ... -
你需要通过viewControllers列举tabBarController&pop到根视图控制器,如果控制器在数组中是UINavigationController like- for(UIViewController *viewController in tabBarController.viewControllers) { if([viewController isKindOfClass:[UINavigationController class]]) [(UINavigation ...
-
找出那些处于类似困境的人。 需要在viewDidLoad添加navigationController?.navigationBar.translucent = false 。 在iOS 7中,通过添加此行,它不会在导航栏下滑动视图。 Figured it out for those in a similar predicament. Need to add navigationController?.navigationBar.translucent = false in viewDidLoad. In i ...
-
-viewWillDisappear:方法不是修改navigationController的视图控制器堆栈的最佳位置,因为它在切换选项卡和在其上按下视图时都会触发。 我玩了一下这个,发现最好的地方是 - [UITabBarControllerDelegate tabBarController:didSelectViewController:]方法。 所以,首先你需要指定一个对象作为标签栏的委托(我使用了app委托)。 将UITabBarController的delegate属性绑定到在代码或Interfac ...
-
弹出回到标签栏控制器中的Root View控制器的问题(Issue with popping back to Root View controller in a tab bar controller)[2021-12-19]
试试这个..可能它会帮助你 NSArray *viewContrlls=[[self navigationController] viewControllers]; for( int i=0;i<[ viewContrlls count];i++) { id obj=[viewContrlls objectAtIndex:i]; if([obj isKindOfClass:[rootController class]]) { ... -
可能的方法是创建UITabBarController的子类并实现UITabBarControllerDelegate协议。 然后你可以实现 - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController 当再次选择特定的viewController时返回NO 。 一种方法是保存最近选择的项目并将其与当前选定的项目进行比较 ...