我正在尝试调用我的 shouldSelectViewController 委托(delegate)函数。但它似乎不起作用。
我做了以下操作,但函数仍然没有被调用
.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
我不确定我在这里遗漏了什么。
最佳答案
加入viewDidLoad
[ self 设置委托(delegate): self ];
关于ios - shouldSelectViewController 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16082061/