gpt4 book ai didi

ios - 屏幕转换期间的 iCarousel Sticks

转载 作者:行者123 更新时间:2023-11-29 10:51:19 31 4
gpt4 key购买 nike

我正在使用 iCarousel。轮播包含大约 10 张图片。当屏幕转换时,图像会卡在下一个屏幕上。我在返回原始屏幕时正在使用 popToRootview。它与 UIImage alloc 有关系吗?

我的代码:

- (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];
}

最佳答案

尝试:

- (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];
}

关于ios - 屏幕转换期间的 iCarousel Sticks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20345854/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com