youknowone / UI7Kit

Backport flat-style UIKit from iOS7 to iOS5+
Other
1.67k stars 199 forks source link

Strange UITabBarItem bug #99

Open iT0ny opened 11 years ago

iT0ny commented 11 years ago

Note: i can't reproduce this bug,kinda random bug.

When selected,icon shifts to a different position(it may even disappear from the visible view(bar item) frame)

PS i assume there's a problem w/ - (id)_updateImageWithTintColor:(UIColor )tintColor isSelected:(BOOL)selected getImageOffset:(UIOffset )offset;

you are not using offset argument

youknowone commented 11 years ago

Thanks. Could you give me environment hints?

  1. OS version
  2. SDK version
  3. Autolayout usage
iT0ny commented 11 years ago
  1. iOS 5/6
  2. iOS 7b6
  3. Disabled
iT0ny commented 11 years ago

just noticed: it only appears in iPhone UI

marcdown commented 11 years ago

I can consistently recreate this issue on the latest version (0.9.7); it occurs every time I dismiss a modal. I am testing on iOS 6 using the iOS 7 GM SDK with Autolayout disabled.

youknowone commented 11 years ago

Would anyone share me bug-reproducable test project?

marcdown commented 11 years ago

https://dl.dropboxusercontent.com/u/5975955/TabBarTest.zip

Test Project includes a tab bar controller containing 3 tab bar items each pointing to a view controller with a button that displays a modal. Once you dismiss the modal the selected tab bar image is offset by 2px in iOS 6 - I have not tested iOS 5.

marcdown commented 11 years ago

@youknowone any update on this?

VincentSit commented 10 years ago

I also have this bug and I found my reason.

My controller hierarchy like below:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UIViewController1 *viewController1 = [[UIViewController1 alloc] initWithNibName:nil bundle:nil];
    UIViewController2 *viewController2 = [[UIViewController2 alloc] initWithNibName:nil bundle:nil];
    UIViewController3 *viewController3 = [[UIViewController3 alloc] initWithNibName:nil bundle:nil];
    UIViewController4 *viewController4 = [[UIViewController4 alloc] initWithNibName:nil bundle:nil];
    UIViewController5 *viewController5 = [[UIViewController5 alloc] initWithNibName:nil bundle:nil];

    UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
    UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:viewController2];
    UINavigationController *navigationController3 = [[UINavigationController alloc] initWithRootViewController:viewController3];
    UINavigationController *navigationController4 = [[UINavigationController alloc] initWithRootViewController:viewController4];
    UINavigationController *navigationController5 = [[UINavigationController alloc] initWithRootViewController:viewController5];

    UITabBarController *tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
    tabBarController.viewControllers = @[navigationController1, navigationController2,
                                         navigationController3, navigationController4, navigationController5];
    self.window.rootViewController = self.tabBarController;
}

UIViewController1 with UIViewController6, UIViewController7,UIViewController8 have same super class called SuperClass.

In SuperClass have a method to change the first tabBar view controller:

- (void)foo {
     UIViewController6 *viewController6 = [[UIViewController6 alloc] initWithNibName:nil bundle:nil];
     // in here, self.navigationController is the first viewController in  tabBarController.viewControllers.
     [self.navigationController setViewControllers:@[viewController6] animated:NO];
}

if I call foo, the first tabBarItem will disappear from the tabbar. but if I change the foo like this, the first tabBarItem will not disappear:

- (void)foo {
     UIViewController6 *viewController6 = [[UIViewController6 alloc] initWithNibName:nil bundle:nil];
     // in here, self.navigationController is the first viewController in  tabBarController.viewControllers.
//     [self.navigationController setViewControllers:@[viewController6] animated:NO];
       [self.navigationController pushViewController:viewController6 animated:NO];
}
bumaociyuan commented 9 years ago

@youknowone any update on this?

kalyan4 commented 8 years ago

My task is to change tabbar iem position change according to user criteria my if-condition not perfectly working at this point CGPoint touchlocation; [pan locationInView:self.view];

if (tabbarview == nil) { tabbarview =[tbItems objectAtIndex:self.tabBarController.selectedIndex]; [self.tabBarController.view addSubview:tabbarview]; } if (fixedPos == 0) { fixedPos=touchlocation.y;

}[tabbarview removeFromSuperview]; tabbarview.center = touchlocation;

if (pan.state == UIGestureRecognizerStateEnded) { // [tabbarview removefromsuperview] [tabbarview removeFromSuperview]; tabbarview =nil; fixedPos = 0;

if(touchlocation.x<4){

    if (touchlocation.x<=109)
    {
        [tbItems exchangeObjectAtIndex:0 withObjectAtIndex:self.tabBarController.selectedIndex];
        NSMutableArray *tvcs=[[self.tabBarController viewControllers]mutableCopy];
        id tempvc=[tvcs objectAtIndex:self.tabBarController.selectedIndex];
        [tvcs removeObject:tempvc];
        [tvcs insertObject:tempvc atIndex:1];
        [self.tabBarController setViewControllers:tvcs animated:YES];

    }else
    if (touchlocation.x>109 && touchlocation.x<=215)
    {
        [tbItems exchangeObjectAtIndex:1 withObjectAtIndex:self.tabBarController.selectedIndex];
        NSMutableArray *tvcs=[[self.tabBarController viewControllers]mutableCopy];
        id tempvc=[tvcs objectAtIndex:self.tabBarController.selectedIndex];
        [tvcs removeObject:tempvc];
        [tvcs insertObject:tempvc atIndex:2];
        [self.tabBarController setViewControllers:tvcs animated:YES];

    }else if (touchlocation.x>215 )
    {
        [tbItems exchangeObjectAtIndex:2 withObjectAtIndex:self.tabBarController.selectedIndex];
        NSMutableArray *tvcs=[[self.tabBarController viewControllers]mutableCopy];
        id tempvc=[tvcs objectAtIndex:self.tabBarController.selectedIndex];
        [tvcs removeObject:tempvc];
        [tvcs insertObject:tempvc atIndex:3];
        [self.tabBarController setViewControllers:tvcs animated:YES];

    }else
    {
        [tbItems exchangeObjectAtIndex:3 withObjectAtIndex:4];
        NSMutableArray *tvcs=[[self.tabBarController viewControllers]mutableCopy];
        id tempvc=[tvcs objectAtIndex:self.tabBarController.selectedIndex];
        [tvcs removeObject:tempvc];
        [tvcs insertObject:tempvc atIndex:4];
        [self.tabBarController setViewControllers:tvcs animated:YES];
    }

}else
{
    [tbItems exchangeObjectAtIndex:3 withObjectAtIndex:4];
    NSMutableArray *tvcs=[[self.tabBarController viewControllers]mutableCopy];
    id tempvc=[tvcs objectAtIndex:self.tabBarController.selectedIndex];
    [tvcs removeObject:tempvc];
    [tvcs insertObject:tempvc atIndex:4];
    [self.tabBarController setViewControllers:tvcs animated:YES];
}

}