Using share kit to post images

526 Views Asked by At

I want to be able to share all the images i have in a NSMutableArray, so when the user is looking at a picture they would like to share, it would send the picture they are currently viewing not just one picture in the array

UIImage *image = [UIImage imageNamed:@"Cats"];
    SHKItem *item = [SHKItem image:image title:@"Take a look at this!"];

    // Make the ShareKit action sheet   
    SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

    // Display the action sheet
    [actionSheet showInView:self.view];

    // this is my array I want it my sharekit will respond to all the items in the array
    NSMutableArray *images = [[NSMutableArray alloc] initWithObjects:@"Cats.png",@"GWB.png",@"Australia.png",nil];  

Basically any picture that i am currently looking at in the UIImageview it will always be sending 'cats.png' but, i want it to send any image that is in the UIImageview.

1

There are 1 best solutions below

1
On BEST ANSWER

If you have an interface that will show 3 different pictures (at different times), you should have a reference to your UIImageView somewhere in code.

Your first line posted above does exactly what you say it does (Makes the share item the cat png). This is hardcoded and you should remedy this by changing it to be more dynamic

// assume the reference to your UIImageView is myImageView
UIImage *image = myImageView.image;
.
.
.

With this solution, your sharing method does not need to know anything about the array of images.

Furthermore
The sharekit is sharing only 1 picture from your array, because you set up the item with the cat png. Even though you set up an array in the code you posted, that array is not interacting with sharekit in any way.