一个tabBarItem偶尔会绘制两个图像

时间:2015-12-29 10:23:21

标签: ios objective-c iphone

enter image description here

我无法弄清楚这是怎么发生的。但是我所做的事情可能会导致它。 1,我已经调整了viewDidLoad& viewDidAppear中的UIViewController

2,AppDelegate's窗口的rootViewController是一个mainViewController(UIViewController)。 我将customNavigationController.view添加到mainViewController.view。 CustomNavigationController的rootViewController是UITabbarController

3,线程问题?

4,当我经常在屏幕上点击并平移时,这种情况随机发生。

这是我的代码: 在我的自定义UITabBarController

- (void)loadViewControllers {
    HomeViewController *homeVC = [[HomeViewController alloc] init];
    [homeVC.tabBarItem setImage:[UIImage imageNamed:@"Home"]];
    [homeVC.tabBarItem setTitle:homeTab];

    ProductsViewController *productsVC = [[ProductsViewController alloc] init];
    [productsVC.tabBarItem setImage:[UIImage imageNamed:@"Products"]];
    [productsVC.tabBarItem setTitle:productsTab];

    DiscoverViewController *discoverVC = [[DiscoverViewController alloc] init];
    [discoverVC.tabBarItem setImage:[UIImage imageNamed:@"Discover"]];
    [discoverVC.tabBarItem setTitle:discoverTab];

    AssetsMainViewController *assetsVC = [[AssetsMainViewController alloc] init];
    [assetsVC.tabBarItem setImage:[UIImage imageNamed:@"Assets"]];
    [assetsVC.tabBarItem setTitle:assetsTab];

    NewsViewController *newsVC = [[NewsViewController alloc] init];
    [newsVC.tabBarItem setImage:[UIImage imageNamed:@"News"]];
    [newsVC.tabBarItem setTitle:newsTab];
    [self setViewControllers:@[homeVC,productsVC, discoverVC, assetsVC, newsVC]];
}

在mainViewController中:

- (void)loadViewController {

    TJSNavigationController *rootNavi = [[TJSNavigationController alloc] initWithRootViewController:[TJSTabBarController sharedSingleton]];

    [rootNavi.view setFrame:CGRectMake(0, 0, tMeasure_Width_Sreen, tMeasure_Height_Screen)];
    [self.view addSubview:rootNavi.view];


    [[TJSTabBarController sharedSingleton] loadViewControllers];
    [[TJSTabBarController sharedSingleton] setDelegate:self];
}

0 个答案:

没有答案