iPhone - 将Sharekit的图像发送到Facebook [英] iPhone - sending an image with Sharekit to Facebook

查看:111
本文介绍了iPhone - 将Sharekit的图像发送到Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ShareKit向Facebook发送评论和图像。一切都工作正常,除非如果没有用户图像存在(在coredata / sqlite数据库),我想发送一个默认的图像。这是我的代码, example.png 是默认图像, initWithData:entity.userImage 是用户添加的图像与他们的iPhone。也许我的if else语句有问题。

I'm using ShareKit to send a comment and an image to facebook. Everything's working fine except that if no user image exists (in the coredata/sqlite db) I would like to send a default image instead. Here's my code, with example.png being the default image and initWithData:entity.userImage being the image the user added with their iPhone. Maybe there's something wrong with my if else statement.

-(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说上传文件必须存在。如果数据库中的记录没有数据库,那么我一直在提供一个默认的图像,我一直在努力解决这个问题。

The problem is that if there is no image in the database Sharekit gives a UIAlert saying that a file must be present in the upload. I was trying to get around this by always providing a default image in case the record in the database doesn't have one.

p>

推荐答案

USE if(entity.image == nil)
相反,这个 if(entity.image = nil){

if (imageView.image == nil) {
                imageView.image = [UIImage imageNamed:@"fbicon.png"];
                SHKItem *item2 = [SHKItem image:imageView.image title:@"Hi"];
                [SHKFacebook shareItem:item2];
            }
            else {
            SHKItem *item1 = [SHKItem image:imageView.image title:@"Hi"];
            [SHKFacebook shareItem:item1];
            }

这篇关于iPhone - 将Sharekit的图像发送到Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆