Carousel rotation


#1

I’m experiencing this rather unsettling behavior.

I have a Carousel in a view. When I’m in portrait orientation everything is fine.

When I rotate the iPad to a landscape orientation the view containing the carousel is resized (becomes wider), the carousel is also resized BUT the panning does not work anymore. I tried to do the following to make sure everything is adjusted correctly during the rotation.

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    self.carousel.panEnabled = YES;
    self.carousel.panGestureFrame = self.carousel.frame;
    [self.carousel redrawCarousel];
}

Unfortunately that does not make any difference.

When I go back to portrait mode than the panning works fine again. It’s like switching to landscape disable it for some reason.

Am I missing anything here?

thanks


#2

Hi Lcavalie,

I set up a simple project, added an SEssentialsCarouselLinear2D to a container view, and that container view to my view controller’s UIView, all my views were fully autoresizable. I tried panning my carousel and it worked as expected in both orientations.

Can I ask exactly which carousel you are using (e.g. SEssentialsCarouselLinear2D, SEssentialsCarouselCylindrical etc.) and any setup code you are using on your carousel? I want to try your exact setup to see if I can replicate the issue your issue.  :smile:

Jan


#3

Yes of course I can send more details.

I have a UIViewController with a NIB containing 2 UIViews (carouselView and detailView). One of those UIViews (carouselView) contains the carousel. It’s a linear 3D.

The exact code is below

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if (self =[super initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil])
    {
        self.title = @"Carousel";
        
        [self.view addSubview:self.carouselView];
        [self.view addSubview:self.detailView];
        
        self.carousel = [[SEssentialsCarouselLinear3D alloc] initWithFrame:self.carouselView.bounds];
        self.carousel.backgroundColor = [UIColor colorWithWhite:0.000 alpha:1.000];
        self.carousel.wrapItems = YES;
        self.carousel.snapToFocusPoint = YES;
        self.carousel.itemSpacingFactor = 0.9f;
        self.carousel.maxNumberOfItemsToDisplay = 10.f;
        self.carousel.scaleFactor = 0.89f;
        self.carousel.tiltFactor = -0.05f;
        
        self.carousel.dataSource = self;
        self.carousel.delegate = self;
        
        self.carousel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
        
        [self.carouselView addSubview:self.carousel];

    }
    return self;
}



Than I have a 
-(int)numberOfItemsInCarousel:(SEssentialsCarousel *)carousel

I have a few more carousel related methods like the usual

-(int)numberOfItemsInCarousel:(SEssentialsCarousel *)carousel


-(UIView *)carousel:(SEssentialsCarousel *)carousel itemAtIndex:(int)index

Not much worth reporting here except maybe that  

-(UIView *)carousel:(SEssentialsCarousel *)carousel itemAtIndex:(int)index

returns a decorated view 

    return [[SEssentialsDecoratedReflectedView alloc] initWithView:cell];

Another related piece of code is

-(void)carousel:(SEssentialsCarousel *)carousel didTapItem:(UIView *)item atOffset:(float)offset
{
    [carousel setContentOffset:offset animated:YES withDuration:1.f];
}

But it’s fairly standard.

Once again the exact description of the problem is as follow.

  • start the app in portrait mode -> carousel is ok

  • switch to landscape -> no more carousel movement

  • switch back to portrait -> carousel is ok again

  • start the app in landscape mode -> carousel is blocked and does not move

  • switch to portrait -> everything becomes normal and the carousel moves just fine

  • switch back to landscape -> carousel is dead again

It really looks like the carousel is blocked when in landscape mode but ok when in portrait. I’m not even sure that switching the orientation is actually causing the problem.

Since my original post I tried to modify the code to make sure the carousel becomes the first responder. It is now:

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    self.carousel.panEnabled = YES;
    self.carousel.panGestureFrame = self.carousel.frame;
    [self.carousel redrawCarousel];
    [self.carousel becomeFirstResponder];
}

but that did not make any difference.

Quite strange.


#4

I can’t seem to replicate the issue. Do you think it would be possible for you to send us in a cut down project that demonstrates the strange behaviour? If so, please send it in to info@shinobicontrols.com and reference this forum post in your email.

Once we get our hands on a project that demonstrates this behaviour we can see the problem first hand and get back to you!

I look forward to your email!

Thanks,
Jan