我正在使用 ShareKit 向 facebook 发送评论和图像。一切正常,除了如果不存在用户图像(在 coredata/sqlite db 中)我想发送默认图像。这是我的代码,example.png
它是默认图像,initWithData:entity.userImage
也是用户使用 iPhone 添加的图像。也许我的 if else 语句有问题。
-(IBAction) fbButton {
SHKItem *item;
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/ae/artist/XXX"];
item = [SHKItem URL:url title:[NSString stringWithFormat:@"Take a look at %@", entity.name]];
[SHKFacebook shareItem:item];
if (entity.image = nil) {
UIImage *image = [UIImage imageNamed:@"example.png"];
SHKItem *item2 = [SHKItem image:image title:nil];
[SHKFacebook shareItem:item2];
} else {
UIImage *image = [[[UIImage alloc] initWithData:entity.userImage] autorelease];
SHKItem *item2 = [SHKItem image:image title:nil];
[SHKFacebook shareItem:item2];
}
[SHK flushOfflineQueue];
}
问题是,如果数据库中没有图像,Sharekit 会给出一个 UIAlert 说明文件必须存在于上传中。我试图通过始终提供默认图像来解决这个问题,以防数据库中的记录没有。
一如既往,感谢您的帮助