Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone ios:如何使用滚动视图将图像从URL加载到页面控件_Iphone_Objective C_Ios_Scrollview_Uipagecontrol - Fatal编程技术网

Iphone ios:如何使用滚动视图将图像从URL加载到页面控件

Iphone ios:如何使用滚动视图将图像从URL加载到页面控件,iphone,objective-c,ios,scrollview,uipagecontrol,Iphone,Objective C,Ios,Scrollview,Uipagecontrol,我是iOS新手。现在我想使用滚动视图将视图图像从URL加载到页面控件。当我运行程序时,会显示第一个图像,但当我尝试滑动到下一个图像或移动到另一个页面时,程序没有响应。我的猜测可能与图像的大小有关 下面是我加载图像的代码。我把这个代码放在-(void)viewDidLOad CGRect screenShot = screenView.frame; screenShot.origin.y = description.frame.origin.y + description.frame.size.h

我是iOS新手。现在我想使用滚动视图将视图图像从URL加载到页面控件。当我运行程序时,会显示第一个图像,但当我尝试滑动到下一个图像或移动到另一个页面时,程序没有响应。我的猜测可能与图像的大小有关

下面是我加载图像的代码。我把这个代码放在-(void)viewDidLOad

CGRect screenShot = screenView.frame;
screenShot.origin.y = description.frame.origin.y + description.frame.size.height + 30;
screenView.frame = screenShot;

pageControlBeingUsed = NO;

for (int i = 0; i < [myArrayImagesURL count]; i++) {
    CGRect frame;
    frame.origin.x = self.scrollView.frame.size.width * i;
    frame.origin.y = 0;
    frame.size = self.scrollView.frame.size;
      UIImageView *iv = [[[UIImageView alloc] initWithFrame:CGRectMake(scrollView.bounds.size.width * i, 0, scrollView.bounds.size.width, scrollView.bounds.size.height)] autorelease];
    iv.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
                                       [NSURL URLWithString:[myArrayImagesURL objectAtIndex:i]]]];

    [self.scrollView addSubview:iv];
    [iv release];
}

self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * [myArrayImagesURL count], self.scrollView.frame.size.height);

self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = [myArrayImagesURL count];
CGRect screenShot=screenView.frame;
screenShot.origin.y=description.frame.origin.y+description.frame.size.height+30;
screenView.frame=屏幕截图;
pageControlBeingUsed=否;
对于(int i=0;i<[myArrayImagesURL计数];i++){
CGRect帧;
frame.origin.x=self.scrollView.frame.size.width*i;
frame.origin.y=0;
frame.size=self.scrollView.frame.size;
UIImageView*iv=[[UIImageView alloc]initWithFrame:CGRectMake(scrollView.bounds.size.width*i,0,scrollView.bounds.size.width,scrollView.bounds.size.height)]自动释放];
iv.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString:[myArrayImagesURL对象索引:i]];
[self.scrollView addSubview:iv];
[四释放];
}
self.scrollView.contentSize=CGSizeMake(self.scrollView.frame.size.width*[myArrayImagesURL计数],self.scrollView.frame.size.height);
self.pageControl.currentPage=0;
self.pageControl.numberOfPages=[myArrayImagesURL计数];

看起来您已将imageView设置为autorelease,并将其发布。这应该是错误的。创建imageView时,请尝试删除自动释放标记。现在应该适当地保留它

UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(scrollView.bounds.size.width * i, 0, scrollView.bounds.size.width, scrollView.bounds.size.height)];

非常感谢这是解决。。。madhumal。。它正在工作^_^不客气,伙计:)如果问题解决了,请将此标记为已回答,谢谢!