Add a default sentence while sharing an image on Facebook - ios

Does anyone know how to set a default sentence when the user shares something on his wall? Im not asking about the the user's text. I'm asking how to show the tagline "... took a photo with ...".

Refer this link.
UIImage *image = [UIImage imageNamed:#"Image.jpg"]; // You Image that u want to share
SHKItem *item = [SHKItem image:image title:#"XXX : took a photo with Instagram"];
[SHKFacebook shareItem:item];
Hope it worked for You.

Related

UIImageView displays downloaded images from HTTP, but won't display image resource

In my first View Controller after a user logs in, there is a quick check to see if the user has uploaded a custom image to his account. (If he has, there's a URL in the user's profile data.)
These images are downloaded correctly in my code and they show up beautifully. The problem comes when there is no custom user image, and the VC tries to set the same UIImageView to a default picture (in xcassets). The picture is being loaded into the bundle, as far as I can tell, and it's a valid PNG file.
Here is the snippet for setting the image. If a custom URL is not found, I set the URL parameter string to "nil."
-(void) setImageWithUrl: (NSString *) Url Imageview: (UIImageView *) image {
if (Url.length > 4) {
NSURL *url = [NSURL URLWithString:Url];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *Profileimage = [UIImage imageWithData:data];
[image setImage:Profileimage];
}
else {
UIImage *Profileimage = [UIImage imageNamed:#"DefaultPicture"];
[image setImage:Profileimage];
}
}
This one's driving me nuts, so all weird ideas are welcome. :-)
Let me know if you want me to post any other parts of the code that you think could be a factor.
It looks like debug-need issue. But why don't you use any image download/cache library, like SDWebImage?
It gonna be much efficient and convenient

UIActivityViewController share to Facebook

I want to use UIActivityViewController to share something to Facebook, and I want to customize my "image card space", So I can click the blue area and direct to other website
the image is from Facebook, and it say the blue area is image card space
this is a screen shot from other app, this app use UIActivityViewController too, so I believe it can be done, I try to search the information about how to implement, but it fail, maybe I use the wrong key word
this is my code
UIImage *Img = [UIImage imageNamed:#"myImg.png"];
NSString *myString = #"hi, I am strign";
NSURL *myUrl = [NSURL URLWithString:#"www.google.com"];
NSArray *items = #[myString, Img, myUrl];
UIActivityViewController *avc = [[UIUIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
self presentViewController:avc animated:YES completion:nil];
and this is what I get
just Image appear
myString does not appear, I guess this is because,it will appear in"user message field", and this is illegal(the first image), so iOS delete it
but where is my URL? if I post this to Facebook, it just a Image, I can't direct to other website
Is anyone know how to customize image card space?
=====================edit==================
ok, i think i got it
the app not customize the area
it just put the url
and iOS get the data automatly, and display it
so, just put url to UIActivityViewController
if anything wrong please re correct me

How can parse all the images form Website in IOS SDK

I like to implement image upload functionality in my app.For that I like to give some option for user to choose image.
One of the option is choose image from website.
If the user enter an url link in the text box and click the get images button means. I like to display all the images in that particular link
But I am not having any idea about this.
I have explain my requirement below
1)Enter the url in a text box
2)Click the get images button
3)Parse all the images from that particular url
4)Display all the images in the Imageview
And also to illustrate my requirement I have attached the screenshot below
If anybody work around this functionality means please suggest me some idea
Thanks
Like this ?
- (IBAction)buttonClicked:(id)sender
{
NSURL *url = [NSURL URLWithString:#"http://www.yourwebvsite.com/image.png"];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData: data];
UIImageView *displayImageView = [[UIImageView alloc] initWithImage:image];
[displayImageView setFrame:CGRectMake(0, 0, 300, 300)];
[displayImageView setContentMode:UIViewContentModeScaleAspectFit];
[self.view addSubview:displayImageView];
}
Or if you want all the images from a web directory. See here and save all the images in an array then display the images in a UIImageView like my code above.

Share MKMapView screenshot

I have a MKMapView and I would like to take a screenshot of it and share it to a social network, for example to Facebook. I've found a nice way to make the screenshot, using MKMapSnapshotter (which is available starting with iOS 7), but my question is: Am I able to share a screenshot of MKMapView? Does Apple allow this?
I found this similar question, but there is not given any clear answer.
Try Google Maps SDK for iOS:
Documentation
And to make the screenshot use the following code:
CGRect rect = [captureView bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[captureView.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Yes of course, why would apple object you?
You can surely share the image. As you mentioned you have the image you just need to use default sharing sheet. here's the code:
NSArray *activityItems = [NSArray arrayWithObjects:yourImage, nil];
UIActivityViewController *aActivityView = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
aActivityView.modalInPopover = UIModalTransitionStyleCoverVertical;
[self presentViewController:aActivityView animated:YES completion:^{
}];
This will present an UIActivityViewController's view which will have share option in it.
Hope this helps.
My gut feeling would be; why wouldn't Apple allow this?
If you have already managed to grab a UIImage representation of your MKMapView using the Apple provided MKMapSnapshotter, I would hazard a guess that Apple have given you the tools you need to do whatever you want with the image so there would be no restrictions as to what you do with it.

ios sharekit 2.0 not showing image preview when sharing image

I'm using Sharekit2.0 to share images to facebook and twitter.
Here is the code used for sharing the image in facebook.
SHKItem *sharerItem = [SHKItem image:image title:#""];
SHKTwitter *sharer = [[SHKTwitter alloc] init];
[sharer setItem:sharerItem];
[sharer share];
But this not showing any preview of the image when sharing (like twitter is showing). just a text view to enter title for image.
My question would be: is it possible to show to image preview when sharing to facebook ?
Thanks
Try:
SHKItem * sharerItem = [SHKItem image:image title:#"P"];
[SHKTwitter shareItem:sharerItem];

Resources