这是我的标签栏的代码
- (void)viewDidLoad {
[super viewDidLoad];
self.title = NSLocalizedString(@"Crops ", @"Articles");
UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 376, 320, 44)];
item1 = [[UITabBarItem alloc] initWithTitle:@"TypesToTry" image:[UIImage imageNamed:@"crops.png"] tag:0];
item2 = [[UITabBarItem alloc] initWithTitle:@"WhenToPlant" image:[UIImage imageNamed:@"crops.png"] tag:1];
NSArray *items = [NSArray arrayWithObjects:item1,item2,item3,item4,item5, nil];
[tabBar setItems:items animated:YES];
[tabBar setSelectedItem:nil];
tabBar.delegate=self;
[self.view addSubview:tabBar];
}
我想要的是每当我点击第一个标签时我想去那个特定的描述,所以在哪里纠正这个动作。请帮助我。 问题可能很简单,但对我来说很困难:),请帮助这位新开发者
由于
答案 0 :(得分:2)
您好我认为您可以添加以下代码行,以使您的标签栏项目可用
[item1 performSelectorOnMainThread:@selector(Yourfunction) withObject:nil waitUntilDone:NO];
[item2 performSelectorOnMainThread:@selector(Yourfunction) withObject:nil waitUntilDone:NO];
把这一行放在 - (void)didLoad的末尾,我希望它对你有用