2
我想弄清楚如何在Web上创建包含图像的MSStickers。我可以创建本地图片MSStickers,例如:使用远程镜像创建MSSticker
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];
但我不能做这样的事情:
NSString *imageURLString = @"https://my-cdn/my-sticker.png";
NSURL *imageURL = [NSURL urlWithString: urlString];
MSSticker *sticker = [[MSSticker alloc] initWithContentsOfFileURL: stickerURL
localizedDescription: @"my-sticker"
error: &err];
当你dl时的远程图像,你所有这些写类型的数组'[URL] '在'文档'中的一个文件中 目录? – SamYoungNY
嘿! Nop,他们必须是适当的文件与他们的文件扩展名(如.png)。这就像将图像下载到您的计算机上。你会发现你的图像从你的“下载”文件夹下载到互联网上吗?这里是一样的,但该文件夹位于您的应用程序目录中。 – RomOne
嘿,谢谢你回来!好吧,我应该DL'ing,转换,然后用以下过程写入图像:'String' - >'URL' - >'NSData' - >'UIImagePNGRepresentation' - >'.writeToFile' - 然后找到目录中的图像(类型为“UIImagePNGRepresentation”)并将其转换为类型“MSSticker”? – SamYoungNY