gpt4 book ai didi

iOS,UITabBarController 中的问题

转载 作者:行者123 更新时间:2023-11-29 03:33:44 24 4
gpt4 key购买 nike

我的bug如下:

在 ViewList 中,我有下面的代码,它会推送 ViewManager;

- (Void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath
{
PropertyManagerViewController propertyManagerViewController * = [[PropertyManagerViewController alloc] initWithNibName: @ "PropertyManagerViewController" bundle: nil];
[self.navigationController pushViewController: propertyManagerViewController animated: YES];

}

在 ViewManager 中创建 UITabBarController:

- (void) createTabBarController
{
       [ ShowTabBarController showTabBar : self.navigationController.tabBarController ] ;

        NSMutableArray * viewControllers = [ [ NSMutableArray alloc ] init ] ;
         UITabBarController * TabBarController = [ [ UITabBarController alloc ] init ] ;

        ViewController * viewController = [ [ ViewController alloc ] initWithNibName : @ " ViewController " bundle: nil ] ;
         UINavigationController * navigationController = [ [ UINavigationController alloc ] initWithRootViewController : ViewController ] ;
         [ ViewControllers addObject : navigationController ] ;

        ViewController2 viewController2 * = [ [ VisitDetailsViewController alloc ] initWithNibName : @ " ViewController2 " bundle: nil ] ;
         UINavigationController * navigationController2 = [ [ UINavigationController alloc ] initWithRootViewController : ViewController2 ] ;
         [ ViewControllers addObject : navigationController2 ] ;

         tabBarController.viewControllers = viewControllers ;
         self.navigationController.tabBarController.viewControllers = tabBarController.viewControllers ;

} .

在 ViewController 和 View ViewController2 中有这个方法来推送 ViewList。

-(void)pushTableList
{
[ShowTabBarController hideTabBar:self.tabBarController];

PropertyListViewController *propertyList = [[PropertyListViewController alloc] initWithNibName:@"PropertyListViewController" bundle:nil];

[UIView beginAnimations:nil 上下文:NULL];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:propertyList animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:NO];

[UIView commitAnimations];
}

我现在的问题是:

  • 当我在 ViewController2 pushTableList 中时,我要查看列表。
  • 然后选择另一行,执行 push ViewManager,显示的 View 是最后一个 View ,在本例中是 ViewController2。

更新:

我想单击表格单元格,然后推送 ViewController。问题是:我点击单元格,当我推送到 ViewList 时, View 显示 ViewContoller 2(这是我的最后一个 View )。

新更新

1 - 推送并创建 UITabBArController

-(Void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath
{
PropertyManagerViewController propertyManagerViewController * = [[PropertyManagerViewController alloc] initWithNibName: @ "PropertyManagerViewController" bundle: nil];
[self.navigationController pushViewController: propertyManagerViewController animated: YES];

}
- (void) createTabBarController
{
[ ShowTabBarController showTabBar : self.navigationController.tabBarController ] ;

NSMutableArray * viewControllers = [ [ NSMutableArray alloc ] init ] ;
UITabBarController * TabBarController = [ [ UITabBarController alloc ] init ] ;

ViewController * viewController = [ [ ViewController alloc ] initWithNibName : @ " ViewController " bundle: nil ] ;
UINavigationController * navigationController = [ [ UINavigationController alloc ] initWithRootViewController : ViewController ] ;
[ ViewControllers addObject : navigationController ] ;

ViewController2 viewController2 * = [ [ VisitDetailsViewController alloc ] initWithNibName : @ " ViewController2 " bundle: nil ] ;
UINavigationController * navigationController2 = [ [ UINavigationController alloc ] initWithRootViewController : ViewController2 ] ;
[ ViewControllers addObject : navigationController2 ] ;
ViewController3 viewController3 * = [ [ VisitDetailsViewController alloc ] initWithNibName : @ " ViewController3 " bundle: nil ] ;
UINavigationController * navigationController3 = [ [ UINavigationController alloc ] initWithRootViewController : ViewController2 ] ;
[ ViewControllers addObject : navigationController3 ] ;

tabBarController.viewControllers = viewControllers ;
self.navigationController.tabBarController.viewControllers = tabBarController.viewControllers ;

}

enter image description here

2 - 选择 TabBarITem Visit Details 然后点击 UIBarButtonItem Property List

enter image description here

3 - 单击 da 表的单元格。

enter image description here

4 - 这是我的问题。如果你回头去tabbaritem访问。我要你给我看 PropertyItem enter image description here

最佳答案

您可能想查看此文档:https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html

一条非常重要的信息:UITabBarController 始终必须是顶级 Controller !不允许将 UITabBarController 放在 UINavigationController 中。但是,您可以将 UINavigationController 放在 UITabBarController 中。 Apple docs关于 UINavigationController 的 pushViewController:animated: 方法说:

The view controller that is pushed onto the stack. This object cannot be an instance of tab bar controller and it must not already be on the navigation stack.

我希望这能为您指明正确的方向。

关于iOS,UITabBarController 中的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19449509/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com