2013-12-03 2 views
1

Я использую iCarousel. Карусель содержит около 10 изображений. Во время переходов экрана изображения застревают на следующем экране. Я использую popToRootview, возвращаясь к исходному экрану. Имеет ли это отношение к UIImage alloc?iCarousel Sticks во время перехода экрана

Мой код:

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel 
{ 
    return ([animals count]); 
} 

- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel 
{ 
    //limit the number of items views loaded concurrently (for performance reasons) 
    return 7; 
} 

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index 
{ 
    NSString *filePath1 = [animals objectAtIndex:index];  
    UIImage *image = [[UIImage alloc] initWithContentsOfFile:filePath1]; 

    //create a numbered view 
    UIView *view = [[UIImageView alloc] initWithImage:image]; 
    view.frame = CGRectMake(0.0f, 0.0f, 230, 150); 
    return view; 
} 

- (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel 
{ 
    //note: placeholder views are only displayed on some carousels if wrapping is disabled 
    return 0; 
} 

- (CGFloat)carouselItemWidth:(iCarousel *)carousel 
{ 
    //usually this should be slightly wider than the item views 
    return 240; 
} 

- (BOOL)carouselShouldWrap:(iCarousel *)carousel 
{ 
    //wrap all carousels 
    return wrap; 
} 

- (void)carouselDidEndScrollingAnimation:(iCarousel *)aCarousel 
{ 
    label.text = [descriptions objectAtIndex:aCarousel.currentItemIndex]; 
    [_label1 setText:[NSString stringWithFormat:@"%ld/%lu", (long)aCarousel.currentItemIndex+1,(unsigned long)[animals count]]]; 
} 

- (IBAction)btnBackAct:(UIButton *)sender 
{ 
    [carousel removeFromSuperview]; 
    //[carousel scrollToItemBoundary]; 
    [carousel scrollToItemAtIndex:0 animated:NO]; 
    [self.navigationController popViewControllerAnimated:YES];  
} 
+0

образы в активах или загружены? – jcesarmobile

+0

Они были загружены. – koherent

+0

Перед показом карусели или пока вы их показываете? – jcesarmobile

ответ

2

попробовать:

- (IBAction)btnBackAct:(UIButton *)sender 
{ 
    [carousel scrollToItemAtIndex:0 duration:0.01]; 
    [self performSelector:@selector(popMyView) withObject:nil afterDelay:0.02]; 
} 

-(void)popMyView 
{ 
    [self.navigationController popViewControllerAnimated:YES]; 
} 
+0

Nope не работает. Все такой же. – koherent

+0

эта проблема сохраняется только при включении анимации. – koherent

+0

работал для меня (Y) –

Смежные вопросы