0
我有一個view1和view2。在view1中,我已經設置了一個帶有兩個標籤欄項目的動態標籤欄。現在我想設置view1,這是我在第一個標籤欄項添加標籤欄。並在第二個標籤欄項目我想設置view2。現在告訴我如何在第一個標籤欄項目上設置view1,以便當用戶點擊標籤欄item1然後再次顯示具有相同數據的view1? 那是怎麼回事?我用這個代碼標籤欄如何設置tabbar的視圖?
- (void)viewDidLoad {
self.title = @"Business Details";
CGRect myTab =CGRectMake(0,368,320,49);
UITabBar *tabBar = [[[UITabBar alloc] initWithFrame:myTab] autorelease];
NSMutableArray *items = [[[NSMutableArray alloc] init] autorelease];
// Add a 'contacts' item
[items addObject:[[[UITabBarItem alloc] initWithTitle:@"Detail View" image:nil tag:1] autorelease] ];
// Add a 'More' item
[items addObject:[[[UITabBarItem alloc] initWithTitle:@"Review" image:nil tag:2] autorelease] ];
// Put the items in the tab bar
tabBar.items = items;
// Setup this object to respond to tab changes
tabBar.delegate = self;
[self.view addSubview:tabBar];
[super viewDidLoad];
}
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
switch (item.tag) {
case 1:
dv=[[[DetailView alloc]initWithNibName:@"DetailView" bundle:nil]autorelease];
[self.navigationController pushViewController:dv animated:YES];
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
break;
case 2:
review_view=[[[Review alloc]initWithNibName:@"Review" bundle:nil]autorelease];
[self.navigationController pushViewController:review_view animated:YES];
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
default:
break;
}
}
在此先感謝...
我想使用它在我的項目的中間,所以我不能使用新的Tabbar應用程序模板。感謝您的建議 – iRam11
好吧病了更新後,希望你能得到你的答案! – JonasG
你能投票嗎?謝謝 – JonasG