4

I am trying to call my shouldSelectViewController Delegate function. But it doesnt seem to work.

I did the following, but still the function doesnt get called

.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

I am not sure what am I missing here.

4

1 回答 1

0

加入viewDidLoad

[自我设置委托:自我];

于 2017-09-28T08:40:49.107 回答