UITabBarController
Martinのチュートリアルを使用してカスタムを作成しました。私のサブクラスはViewControllerFSTabBarController
を切り替え、私が見る限り正常に動作します。
問題は、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 !!
}