2014-01-29 30 views
1

如何實現在一個UITableViewController一個UITabBarItem?UITabBarItem沒有的UITabBarController

我怎麼實現的TabBar項的動作(點擊) - 收藏用的方法?

這是我tableviewcontroller.h

@interface bibliotecaViewFinale : UITableViewController 
@property (strong, nonatomic) IBOutlet UITabBarItem *myTabBar; 
@property (strong, nonatomic)Aule_Biblioteche *aulebib; 
@property (strong, nonatomic) IBOutlet UILabel *label_info; 
@property (nonatomic,strong) NSArray *infobib; 
@end 

我應該在.M寫?

回答

1

不知道你想要什麼來實現的,但如果你需要的標籤欄控制器內表視圖(控制器),你應該使用默認或編寫自定義標籤欄控制器,並把TVC作爲一個孩子。

如果你只需要一個按鈕,看起來像標籤欄項目,還是應該寫與表視圖作爲一個子視圖自定義視圖。

0

我有同樣的想法,做出的tabbaritems的行爲像一個的UIButton,而其他人充當normal.Here是我的代碼:

@interface myTabBarVC()<UITabBarControllerDelegate> 
@end 

@implementation myTabBarVC 
-(void)viewDidLoad{ 
    [super viewDidLoad]; 
    self.delegate=self; 
} 
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{ 
NSInteger itemindex = [self.viewControllers indexOfObject:viewController]; 
if (itemindex == 0) {//change 0 to any tabbaritem's index your want to change 
    //add action here 
    return NO; 
} 
return YES; 
} 
@end 

唯一的問題是這個tabbaritem行爲像解開,它的顏色韓元當你選擇它時不會改變。我無法解決它。

相關問題