ビューベースのアプリケーションで3つの項目を持つタブバーを作成しました。
ビューが表示されたら、最初のアイテムがデフォルトで選択されます。ビューベースのアプリケーションのTabbar項目が機能しない
問題はitem1の表示が選択されていますが、表示されている表示が読み込まれません。アイテムをクリックすると、ビューが表示されます。これを整理するのを手伝ってください。ここに私のコードは...
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
tabBar.delegate = self;
[tabBar setSelectedItem:[tabBar.items objectAtIndex:0]];
}
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
NSLog(@"didSelectItem: %d", item.tag);
if (item.tag==1) {
ImagesOverlay=[[UIView alloc]initWithFrame:CGRectMake(0, 210, 320, 250)];
ImagesOverlay.backgroundColor=[UIColor grayColor];
[self.view addSubview:ImagesOverlay];
}else if (item.tag==2) {
relatedOverlay=[[UIView alloc]initWithFrame:CGRectMake(0, 210, 320, 250)];
relatedOverlay.backgroundColor=[UIColor redColor];
[self.view addSubview:relatedOverlay];
}else if(item.tag==3){
//other condition
}
}
彼は 'UITabBar'、ない' UITabBarController'を使用しているように見える:クラスリファレンスの読み取りを持っています。 –