2010-12-20 85 views
1

这是我的代码为我的标签栏如何给行动标签栏项目

- (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]; 
} 

我要的是每当我点击第一选项卡我要到那个特定的描述,所以在哪里正确的行动。请帮助我。 该问题可能很简单,但对我来说,他们是很难:),请帮助这个新的开发

感谢

回答

2

嗨,我想你可以添加以下代码行,让您的标签栏项目可行

[item1 performSelectorOnMainThread:@selector(Yourfunction) withObject:nil waitUntilDone:NO]; 

[item2 performSelectorOnMainThread:@selector(Yourfunction) withObject:nil waitUntilDone:NO]; 

把这行放在 - (void)didLoad的末尾,我希望它能为你工作