Skip to content

Control not displayed properly after rotating in another view controller #49

@nickygerritsen

Description

@nickygerritsen

I'm not sure if it is linked to issue #44, but I have found another bug: when rotating the device when the segmented control is not visible (i.e. in another view controller) and then returning to the view controller again, the paths aren't drawn correctly.

To reproduce:

Create an empty iOS application, add SDSegmentedControl and use this as the application: didFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIViewController *firstVC = [[UIViewController alloc] init];
    firstVC.title = @"Segment";
    UIViewController *secondVC = [[UIViewController alloc] init];
    secondVC.title = @"Dummy";

    SDSegmentedControl *segmentController = [[SDSegmentedControl alloc] initWithItems:@[@"1", @"2"]];
    segmentController.frame = CGRectMake(0, 0, self.window.frame.size.width, segmentController.frame.size.height);

    [firstVC.view addSubview:segmentController];

    UITabBarController *rootController = [[UITabBarController alloc] init];
    [rootController addChildViewController:firstVC];
    [rootController addChildViewController:secondVC];
    self.window.rootViewController = rootController;
    [self.window makeKeyAndVisible];
    return YES;
}

Now start the application. The following scenario works as expected:

  • Switch to second tab
  • Rotate device to landscape
  • Switch back to first tab

But the following does not work as expected:

  • Rotate the device to landscape and back to portrait
  • Switch to second tab
  • Rotate device to landscape
  • Switch back to first tab

In this second case, the paths that are drawn only occupy the 320 points of the portrait mode.

I already found that it goes wrong in the function that draws the paths and only when the duration > 0. But then I got stuck trying to fix it...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions