2011-06-29 15 views
6

sé cómo mostrar una imagen solitaria:de intercambio de múltiples elementos con sharekit en facebook

// Create a UIImage. 
UIImage *image = [UIImage imageNamed:@"ShareKit.jpg"]; 

// Wrap the UIImage within the SHKItem class 
SHKItem *item = [SHKItem image:image title:@"This image was sent with ShareKit!"]; 

// Create a ShareKit ActionSheet and Assign the Sheet an SHKItem 
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; 

// Display the ActionSheet in the current UIView 
[actionSheet showInView:self.view]; 

y cómo compartir un enlace solitaria:

// Create an NSURL. This could come from anywhere in your app. 
NSURL *url = [NSURL URLWithString:@"http://mobile.tutsplus.com"]; 

// Wrap the URL within the SHKItem Class 
SHKItem *item = [SHKItem URL:url title:@"Mobiletuts!"]; 

// Create a ShareKit ActionSheet and Assign the Sheet an SHKItem 
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; 

// Display the ActionSheet in the current UIView 
[actionSheet showInView:self.view]; 

pero no sé cómo compartir tanto enlace como imagen al mismo tiempo. ¿Puede alguien ayudarme con esto?

Respuesta

2


Puede hacerlo de dos maneras.

1. Mediante la propiedad URL de SHKItem.

@property (nonatomic, retain) NSURL *URL; 

así:

NSURL *url = [NSURL URLWithString:@"http://mobile.tutsplus.com"]; 
UIImage *image = [UIImage imageNamed:@"ShareKit.jpg"]; 
SHKItem *item = [SHKItem image:image title:@"This image was sent with ShareKit!"]; 
[item setURL:url]; 


2. Uso de la + [itemFromDictionary:] método de la clase de SHKItem

+ (SHKItem *)itemFromDictionary:(NSDictionary *)dictionary; 

así:

NSString *urlString = @"http://mobile.tutsplus.com"; 
UIImage *image = [UIImage imageNamed:@"ShareKit.jpg"]; 
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:urlString, @"URL", image, @"image", @"This image was sent with ShareKit!", @"title", nil]; 
SHKItem *item = [SHKItem itemFromDictionary:dictionary]; 


... y luego compartir su artículo como se desee. En su caso, puede visualizar usando el método - [actionSheetForItem:].

+0

hola ... ¿le interesaba cómo agregar la descripción también? ¿Quiere decir texto, url e imagen al mismo tiempo? – lakesh

+0

alguna idea sobre eso? necesito alguna guía? – lakesh

+0

@lakesh el ejemplo que he dado muestra el texto, la URL y la imagen que se comparten en una solicitud. Vea cómo el diccionario usa 3 pares de clave-objeto en su creación de instancias. – imnk

Cuestiones relacionadas