AppDelegate.h *****
@interface AppDelegate : UIResponder <UIApplicationDelegate,UITabBarControllerDelegate,UITabBarDelegate>
AppDelegate.m *****
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
NSLog(@"%lu",(unsigned long)tabBarController.selectedIndex);
}
这种方法不起作用吗? 我想在单击标签栏项目时滚动顶部 请帮助:)
答案 0 :(得分:1)
您只需在第一个viewController的viewDidLoad方法中添加此行:
self.tabBarController.delegate = ((AppDelegate *)[UIApplication sharedApplication].delegate);