Trong tập tin tiêu đề của tôi, tôi có điều này:TabBar didSelectItem dường như không có tác dụng
@interface TabBarController : UIViewController <UIApplicationDelegate, UITabBarDelegate, UITabBarControllerDelegate>{
IBOutlet UITabBarController *tabBarController;
}
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end
Trong tập tin chính của tôi, tôi có điều này:
@synthesize tabBarController;
-(void)viewDidLoad{
[super viewDidLoad];
self.tabBarController.delegate = self;
self.view = tabBarController.view;
}
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
NSLog(@"rawr");
}
- (void)viewDidUnload {
[super viewDidUnload];
}
- (void)dealloc {
[tabBarController release];
[super dealloc];
}
@end
Tôi đã kết nối tôi tabbarcontroller
như một đại biểu đến chủ sở hữu tệp của tôi trong trình tạo giao diện nhưng vẫn không bao giờ gọi phương thức didSelectItem
.
Có bất kỳ điều gì tôi thiếu ở đây không?
Tôi đã thêm tabBarController.delegate = self;
và nó vẫn không hoạt động.
Nếu bạn làm điều đó theo lập trình thì sao? I. e., 'TabBarController.delegate = self;'? –
nó stil không hoạt động :( –