Iphone ViewXcode似乎不工作
海,, 我已经创建了一个基于选项卡的iRestaura项目。我使用5个选项卡栏项。选项卡栏名称之一是Customer。当我点击customer时,会以编程方式使用3 viewcontroller创建另一个选项卡栏。当我使用view didload方法时,tabbarcontroller已成功创建。但当我使用view时,tabbar控制器并不是由tabbar创建的。在这两种情况下,以编程方式创建的其他三个viewcontroller“没有显示视图”都不起作用。但在所有情况下,我都需要使用ViewDidAspect方法。 请任何人都能帮我。。。 下面给出了不起作用的VIEWDIDEDISPENCE方法Iphone ViewXcode似乎不工作,iphone,objective-c,Iphone,Objective C,海,, 我已经创建了一个基于选项卡的iRestaura项目。我使用5个选项卡栏项。选项卡栏名称之一是Customer。当我点击customer时,会以编程方式使用3 viewcontroller创建另一个选项卡栏。当我使用view didload方法时,tabbarcontroller已成功创建。但当我使用view时,tabbar控制器并不是由tabbar创建的。在这两种情况下,以编程方式创建的其他三个viewcontroller“没有显示视图”都不起作用。但在所有情况下,我都需要使用ViewD
- (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]);
}
}
试试这个:
首先在Tabbar controller.m文件上使用以下函数:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[viewController viewWillAppear:YES];
}
在Tabbar controller.m文件的viewDidLoad函数中,使用localNavigationController.delegate=self;如下例所示
UserListing *nearBy = [[UserListing alloc] init];
nearBy.tabBarItem.image = [UIImage imageNamed:@"icoTabNearby.png"];
nearBy.tabBarItem.title = @"Nearby";
localNavigationController = [[UINavigationController alloc] initWithRootViewController:nearBy];
localNavigationController.delegate = self;
希望它对你有用。hai,谢谢你的回答。实际上我已经试过了。这仅适用于我的“客户”选项卡,但在这里,我正在“客户”中创建其他3个uiview控制器。t您必须使用localNavigationController.delegate=self;分别适用于所有ViewController