【发布时间】:2011-03-22 06:23:23
【问题描述】:
嘿, 我创建了一个基于选项卡的 iRestaura 项目。我使用 5 个标签栏项目。标签栏名称之一是客户。当我点击客户时,另一个标签栏会以编程方式使用 3 个视图控制器创建。当我使用 view didload 方法 tabbarcontroller 创建成功。但是当我使用视图 didAppear 时,不会创建标签栏控制器。在这两种情况下,以编程方式创建的其他三个视图控制器,没有视图确实出现不工作。但所有情况下我都需要使用 viewDidAppear 方法。 LZ任何人都可以帮助我... 下面给出了不起作用的 viewDidAppear 方法.....
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UITabBarController *tabBarController1=[[UITabBarController alloc] init];
CustomerListViewController *customerListViewController=[[CustomerListViewController alloc] init];
customerListViewController.title=@"Customer List";
UIImage *anImage1 = [UIImage imageNamed:@"customer.png"];
UITabBarItem *theItem1 = [[UITabBarItem alloc] initWithTitle:@"CustomerList" image:anImage1 tag:0];
customerListViewController.tabBarItem = theItem1;
SelectedCustomerViewController *selectedCustomerViewController= [[SelectedCustomerViewController alloc] init];
selectedCustomerViewController.title=@"Selected Customer";
UIImage *anImage3 = [UIImage imageNamed:@"selectedCustomer.png"];
UITabBarItem *theItem = [[UITabBarItem alloc] initWithTitle:@"Selected Customer" image:anImage3 tag:1];
selectedCustomerViewController.tabBarItem = theItem;
InvoiceListViewController *invoiceListViewController=[[InvoiceListViewController alloc] init];
invoiceListViewController.title=@"Invoice List";
UIImage *anImage2 = [UIImage imageNamed:@"invoiceNo.png"];
UITabBarItem *theItem2 = [[UITabBarItem alloc] initWithTitle:@"Invoice List" image:anImage2 tag:2];
invoiceListViewController.tabBarItem = theItem2;
NSMutableArray *controllers=[[NSMutableArray alloc] init];
[controllers addObject:customerListViewController];
// [controllers1 addObject:vc1];
[controllers addObject:selectedCustomerViewController];
[controllers addObject:invoiceListViewController];
///[controllers1 addObject:vc4];
tabBarController1.viewControllers=controllers;
[self.navigationController setNavigationBarHidden:YES animated:YES];
[[self view] addSubview:tabBarController1.view];
for (int t=0; t<[controllers count]; t++)
{
NSLog(@"controller%@",[controllers objectAtIndex:t]);
}
}
【问题讨论】:
标签: iphone objective-c