shouldSelectViewController没有被调用

时间:2013-04-18 11:46:19

标签: ios uitabbarcontroller uitabbar appdelegate

我正在尝试调用我的shouldSelectViewController委托函数。但它似乎没有用。

我做了以下操作,但仍然没有调用函数

的.h

@interface myAppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

的.m

@implementation TakeFiveCameraAppDelegate

@synthesize window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{   
    UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
    tabBarController.delegate = (id)self;
    return YES;
}

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    NSLog(@"test");
    return YES;
}

@end

我不确定我在这里失踪了什么。

1 个答案:

答案 0 :(得分:0)

添加viewDidLoad

[self setDelegate:self];