我UITabBarController
使用 Martin 的教程创建了一个自定义。我的子类FSTabBarController
在视图控制器之间切换,并且据我所见表现正常。
问题是,当我将 tabBarContoller 更改为我的子类时,它不会响应我的委托;
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
如果我将它改回 -UITabBarController
当我使用默认值UITabBarController
时 - 代表会正常工作。
自定义子类使用以下函数来表示选项卡选择:
- (void)_buttonClicked:(id)sender
{
self.selectedIndex = [sender tag];
[self _updateTabImage];
}
编辑:
AppDelegate.h
...
@interface AppDelegate : UIResponder <UIApplicationDelegate,UITabBarControllerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) FSTabBarController *tabBarController;
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
self.tabBarController = [[FSTabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:peopleViewController,viewController,profileViewController, nil];
self.tabBarController.delegate = self;
...
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
// not called when FSTabBarController, called when UITabBarController !!
}