问题
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:
- Download the picture from your server
- Store it on local directory of the device
- Use the URL of this local file to create your sticker
- 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