2010-12-20 64 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的末尾,我希望它能爲你工作