Creating a MSSticker with a remote image

时间秒杀一切 提交于 2019-12-22 19:01:52

问题


I am trying to figure out way to create MSStickers with images that are hosted on the web. I can create MSStickers with local images, e.g.:

NSString *imagePath = [[NSBundle mainBundle] pathForResource: @"image_name" 
                                                      ofType: @"png"];
NSURL *imageURL = [NSURL fileURLWithPath: urlString];
MSSticker *sticker = [[MSSticker alloc] initWithContentsOfFileURL: stickerURL
                                             localizedDescription: @"my-sticker"                                          
                                                            error: &err];

But I cannot do something like this:

NSString *imageURLString = @"https://my-cdn/my-sticker.png"; 
NSURL *imageURL = [NSURL urlWithString: urlString];
MSSticker *sticker = [[MSSticker alloc] initWithContentsOfFileURL: stickerURL
                                             localizedDescription: @"my-sticker"                                          
                                                            error: &err];

回答1:


No, it's not possible for the moment. But you can do this, which is not that far from what you want:

  1. Download the picture from your server
  2. Store it on local directory of the device
  3. Use the URL of this local file to create your sticker
  4. Optional : If you don't need the image anymore, erase it from the directory


来源:https://stackoverflow.com/questions/39086845/creating-a-mssticker-with-a-remote-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!