简体   繁体   English

图像未在iPhone中加载

[英]image is not loading in iphone

I have created own listmodel and override its methods and image is displaying in android but in iphone it displays image first time and when back and return to the page then it dispays only white screen , how to solve it? 我已经创建了自己的listmodel并覆盖了它的方法,并且图像在android中显示,但是在iphone中,它第一次显示图像,当返回并返回页面时,它只显示白屏,如何解决呢?

@Override
public Image getItemAt(final int index) {
    if (images[index] == null) {
        String imageName = "image_" + urls.get(index).hashCode();
        if (Storage.getInstance().exists(imageName)) {
            InputStream is;
            try {

                is = Storage.getInstance().createInputStream(imageName);
                EncodedImage i = EncodedImage.create(is, is.available());
                images[index] = i;
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        } else {
            images[index] = defaultImage;
            Util.downloadUrlToStorageInBackground(urls.get(index), imageName, (e) -> {
                try {
                    images[index] = EncodedImage.create(Storage.getInstance().createInputStream(imageName));
                    listeners.fireDataChangeEvent(index, DataChangedListener.CHANGED);
                } catch (IOException err) {
                    err.printStackTrace();
                }
            });
        }

    }

    return images[index];
}

You seem to return null for missing images which might be a problem. 您似乎为丢失的图像返回null ,这可能是一个问题。 You need to return placeholder values and replace them later. 您需要返回占位符值并在以后替换它们。

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

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