大佬教程收集整理的这篇文章主要介绍了iphone – 标签栏控制器(故事板模板)和AppDelegate,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
AppDelegate.h:
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong,nonatomiC) UIWindow *window; @end
AppDelegate.m:
@interface AppDelegate() @property (nonatomic,assign) UIViewController<SubViewContainer> *currentController; @end @synthesize window = _window @synthesize currentController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //I need this piece of code to equal the Tab Bar Controller current tab self.currentController = ? return YES; } //And I'm gonna use this void for some statements about the Tab Bar Controller tabs: - (void)tabBarController:(UITabBarController *)tabBarController didSELEctViewController: (UIViewController *)viewController { // with some statements }
NSLog(@"Root: %@",self.window.rootViewController); UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
通常,您可以使用当前控制器…
self.currentController = [tabController SELEctedViewController];
…但是由于此方法执行时没有选择任何控制器,因此最好猜测你想要的是……
self.currentController = [[tabController viewControllers] objectATindex:0];
以上是大佬教程为你收集整理的iphone – 标签栏控制器(故事板模板)和AppDelegate全部内容,希望文章能够帮你解决iphone – 标签栏控制器(故事板模板)和AppDelegate所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。