Ios ScrollView未使用imageview更新
我的主捆绑包中有20个图像,我想在水平滚动视图中显示它 我成功地做到了这一点,但现在的问题是,在所有imageview都设置为scroll view之后,图像在scrollview中可见,这需要时间 为了解决这个问题,我创建了一个NSO操作Ios ScrollView未使用imageview更新,ios,objective-c,ipad,nsoperation,nsoperationqueue,Ios,Objective C,Ipad,Nsoperation,Nsoperationqueue,我的主捆绑包中有20个图像,我想在水平滚动视图中显示它 我成功地做到了这一点,但现在的问题是,在所有imageview都设置为scroll view之后,图像在scrollview中可见,这需要时间 为了解决这个问题,我创建了一个NSO操作 -(BOOL)sync:(NSError**)error { float imageLeftPosition = 0; for (int imageCount = 1; imageCount<=syncObject.syncNumbe
-(BOOL)sync:(NSError**)error
{
float imageLeftPosition = 0;
for (int imageCount = 1; imageCount<=syncObject.syncNumberOfImages; imageCount++) {
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(imageLeftPosition, 0, syncObject.syncImageWidth, syncObject.syncImageHeight)];
[imgView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d_%d.jpg",syncObject.syncChapterNumber,imageCount]]];
imgView.tag = imageCount;
// NSDictionary *dictionary = [NSDictionary new];
//
// [dictionary setValue:imgView forKey:CHAPTER_IMAGE];
imageLeftPosition = imageLeftPosition+syncObject.syncImageWidth;
//[dictionary setValue:[NSString stringWithFormat:@"%f",imageLeftPosition] forKey:CHAPTER_SCROLL_LEFT_POSITION];
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:imgView,[NSString stringWithFormat:@"%f",imageLeftPosition], nil] forKeys:[NSArray arrayWithObjects:CHAPTER_IMAGE,CHAPTER_SCROLL_LEFT_POSITION, nil]];
[self sendNotification:dictionary];
imgView = nil;
dictionary = nil;
}
return YES;
}
这是通知处理程序方法,我在滚动视图中为主线程上的每个循环设置内容大小和图像视图。加载所有图像后,仍然可以看到滚动视图
我做错了什么?尝试使用pagedflowview。这将仅将可见项加载到Scrollview中,并且易于自定义。你也可以搜索伊卡鲁塞尔 试试这个
-(void)showimagesasSlide:(int) totalimagesCount
{
int xAxisofimageView=0;
for (int initialimagesCount=0;initialimagesCount<totalimagesCount; initialimagesCount++) {
UIImageView *detailedImageview=[[UIImageView alloc] init];
detailedImageview.userInteractionEnabled=YES;
UIImage *dynamicImage=[ScaleImageSize squareImageWithImage:[images objectAtIndex:initialimagesCount] scaledToSize:CGSizeMake(300, 500) ];
if (IS_IPHONE_5) {
detailedImageview.frame=CGRectMake(xAxisofimageView, 0, 320, 568);
}
else
{
detailedImageview.frame=CGRectMake(xAxisofimageView, 0, 320, 460);
}
// detailedImageview.contentMode=UIViewContentModeCenter;
detailedImageview.backgroundColor=[UIColor clearColor];
detailedImageview.image=dynamicImage;
detailedImageview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin ;
detailedImageview.tag=initialimagesCount+12;
[mainScrollview addSubview:detailedImageview];
xAxisofimageView=xAxisofimageView+320;
}
mainScrollview.contentSize=CGSizeMake(320*images.count, 0);
}
是的,这是一个选项,但我想知道当前逻辑的问题是什么。内容大小是否在此[[dictionary valueForKey:CHAPTER\u SCROLL\u LEFT\u POSITION]floatValue]中正确,使用静态值作为图像计数*图像大小进行交叉检查。
-(void)showimagesasSlide:(int) totalimagesCount
{
int xAxisofimageView=0;
for (int initialimagesCount=0;initialimagesCount<totalimagesCount; initialimagesCount++) {
UIImageView *detailedImageview=[[UIImageView alloc] init];
detailedImageview.userInteractionEnabled=YES;
UIImage *dynamicImage=[ScaleImageSize squareImageWithImage:[images objectAtIndex:initialimagesCount] scaledToSize:CGSizeMake(300, 500) ];
if (IS_IPHONE_5) {
detailedImageview.frame=CGRectMake(xAxisofimageView, 0, 320, 568);
}
else
{
detailedImageview.frame=CGRectMake(xAxisofimageView, 0, 320, 460);
}
// detailedImageview.contentMode=UIViewContentModeCenter;
detailedImageview.backgroundColor=[UIColor clearColor];
detailedImageview.image=dynamicImage;
detailedImageview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin ;
detailedImageview.tag=initialimagesCount+12;
[mainScrollview addSubview:detailedImageview];
xAxisofimageView=xAxisofimageView+320;
}
mainScrollview.contentSize=CGSizeMake(320*images.count, 0);
}