【发布时间】:2016-02-28 18:22:09
【问题描述】:
我正在开发一个深度链接应用程序,我需要将我的深度链接管理器的委托分配给我的 tabbarcontroller 子类
如何从标签栏控制器的子类中返回根标签栏控制器?
这是 app del 函数,我在其中调用 [TMDeeplinkManager searchForPodcast...] [self.mainTabController getMainTabBarController] 我想将其更改为
[TMMainTabBarController mainTabBarController]
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
NSNumber *collectionId = [url host];
NSString *episodeTitle = [NSString stringWithFormat:@"%@", [url lastPathComponent]];
[TMDeeplinkManager searchForPodcastWithCollectionID:collectionId
title:episodeTitle
andDelegate:[self.mainTabController getMainTabBarController]];
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
这是 tabbarcontroller 的子类,如何在 instancetype 中返回根视图控制器?不使用应用程序del?
@interface TMMainTabBarController () <UINavigationControllerDelegate>
@property (strong, nonatomic) id selectedItem;
@end
@implementation TMMainTabBarController {
TMMainTabBarController *mainTabBarController;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)didSelectEpisode:(TMPodcastEpisode *)episode {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil] ;
TMAudioPlayerViewController *audioPlayerViewController = [storyboard instantiateViewControllerWithIdentifier:@"TMAudioPlayerViewController"];
audioPlayerViewController.episode = episode;
UINavigationController *mainNavController = self.viewControllers[0];
[mainNavController pushViewController:audioPlayerViewController animated:true];
}
-(void)setMainTabBarController:(TMMainTabBarController *)tabBarController {
mainTabBarController = tabBarController;
}
-(TMMainTabBarController *)getMainTabBarController {
return mainTabBarController;
}
+(instancetype)mainTabBarController {
return self.mainTabBarController;
}
@end
【问题讨论】:
标签: ios objective-c instance multiple-instances rootview