简体   繁体   English

Scrollview不显示图像

[英]Scrollview not shwoing images

i have retrived images from document directory and want to display that images in scrollview. 我已从文档目录中检索图像,并希望在滚动视图中显示该图像。 the images is coming from the document directory but not displaying in scrollview. 图像来自文档目录,但未显示在滚动视图中。 i have the below code. 我有以下代码。 I have put scrollview graipically on xib and also creat outlet.. 我已经将xibgraview放到了xib上,还创建了出口。

self.scrollView.contentSize = CGSizeMake(320, 136);
self.scrollView.delegate = self;
int X=0;
for (int i = 0; i < [imageFileNames count]; i++)
{
    NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:[NSString     stringWithFormat:@"%d/%d.png",b, i]];
    UIImage *img = [UIImage imageWithContentsOfFile:getImagePath];
    [images addObject:img];
    NSLog(@"%@",getImagePath);
    //imge.image=img;

    UIImageView *imageView = [[UIImageView alloc] initWithFrame: CGRectMake(X, 0, 100, 100)] ;
    [imageView setImage: [UIImage imageNamed:[NSString stringWithFormat:@"%d.png", i]]];
    [self.scrollView addSubview: imageView];
    X = X + imageView.frame.size.height+5;

    if(X > 320)
        self.scrollView.contentSize = CGSizeMake(X, 140);
}

Seems you are trying to create the UIImageView from images that are located in your resources (but they are not there!). 似乎您正在尝试根据资源中的图像创建UIImageView(但它们不存在!)。

[imageView setImage: [UIImage imageNamed:[NSString stringWithFormat:@"%d.png", i]]];

whats the point of placing the images in a array, if you dont use it? 如果不使用图像,将图像放置在阵列中有什么意义?

try this instead: 试试这个代替:

[imageView setImage: [images objectAtIndex:i]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM