Need to post to facebook and twitter from an ios app - objective-c

I've been doing some research on how to post to fb and to twitter... I know there is a library called Sharekit and I also know I can post using the new iOS6 feature SLComposeViewController... I just need to post a text, that's all... It's not necessary that the user can edit the message...
I need some advice, what would you use?

If you're ok supporting only iOS6, SLComposeViewController is probably easiest. On the Facebook side, you lose nice little features offered via the Facebook SDK for iOS (e.g., the ability to have the Facebook post bear some indication that it came from your app, the graceful inclusion of both images and URLs, etc.).
Bottom line, if you're ok with iOS6-only and you want to keep it simple, SLComposeViewController is probably easiest and can do both Twitter and Facebook. If you want to make the most of Facebook or if you have to support iOS 5, you really have to pursue the Facebook SDK, but it takes a little more code. On the Twitter side, if you need to support iOS 5, then you need to use TWTweetComposeViewController.

Try this one:
- (IBAction)share:(id)sender
{
NSString *text = #"Your message";
UIImage *image = [UIImage imageNamed:#"yourimage.png"];
NSArray *items = [NSArray arrayWithObjects:text,image , nil];
UIActivityViewController *avc = [[avcClass alloc] initWithActivityItems:items applicationActivities:nil];
avc.excludedActivityTypes = #[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll, UIActivityTypeMessage, UIActivityTypeMail];
[self presentViewController:avc animated:YES completion:nil];
}
This should work for you. Just set the NSString and if you want an image.
No frameworks needed!

Related

how can i show the pdf hyper link data in popover in iPad apps?

i have worked pdf file reader in iPad apps using QLPreviewcontroller but i need to show the inside of pdf hyper link show on popover in iPad any one can help out.
documentPath = [[NSBundle mainBundle] pathForResource:#"my_file" ofType:#"pdf"];
fileURL = [NSURL fileURLWithPath:documentPath];
//fileURL = [NSURL URLWithString:kStringURLUIDocumentInteractionControllerPDF];
}
//creating the object of the QLPreviewController
QLPreviewController *previewController = [[QLPreviewController alloc] init];
//settnig the datasource property to self
previewController.dataSource = self;
//pusing the QLPreviewController to the navigation stack
[[self navigationController] pushViewController:previewController animated:YES];
//remove the right bar print button
[previewController.navigationItem setRightBarButtonItem:nil];
[previewController release];
What you are asking is not impossible, but is extremely complicated and likely will take thousands of lines of code. Quartz has all the functions you'll need to do what your asking, but it will be a major undertaking into poorly documented structures.
This would be much more possible to accomplish using an external library. I've done it before with PSPDFKit as well as Foxit Embedded SDK, but neither is cheap. If your code is GPL licensed, you could consider MuPDF, but it's probably not helpful for commercial software.

Facebook, Twitter icon not showing in UIActivityViewController on iOS7

I have added this code for presenting a UIActivityViewController:
-(IBAction)activityAction:(id)sender
{
UIActivityViewController *activityViewController = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:#"Hello Welcome!",[UIImage imageNamed:#"scene3.jpg"],nil] applicationActivities:nil];
activityViewController.excludedActivityTypes = #[UIActivityTypePostToFacebook, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo, UIActivityTypeAssignToContact];
[self presentViewController:activityViewController animated:YES completion:nil];
}
Facebook, Twitter and Weibo icons are not showing in iOS7. In iOS6, all the icons are showing correctly. See the screenshot below:
How can I solve this?
You're probably not logged in to Facebook or Twitter in the devices Settings. They won't show up here unless the user is logged in. File a bug with Apple.
Look at the name of the property excludedActivityTypes, you are excluding facebook, twitter, ...
activityViewController.excludedActivityTypes = #[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact];
excludes only Weibo and Assign to contact
Make sure that you don't exclude the Activities that you want to use.
So, remove "UIActivityTypePostToFacebook" & "UIActivityTypePostToTwitter" from "activityViewController.excludedActivityTypes" object.
Also, Make sure that you are logged in into Facebook and Twitter accounts in order to post on respective social platform.
Please note that this is working on simulator and real devices.
Hope this helps you.
Your code,
activityViewController.excludedActivityTypes = #[UIActivityTypePostToFacebook, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo, UIActivityTypeAssignToContact];
Change to this,
activityViewController.excludedActivityTypes = #[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact];
And if you have to logged into facebook, twitter on your device settings. Then only it will be visible.
Thanks,
Don't include UIActivityTypePostToFacebook in
activityViewController.excludedActivityTypes = #[UIActivityTypePostToTwitter, UIActivityTypePostToWeibo, UIActivityTypeAssignToContact];
[self presentViewController:activityViewController animated:YES completion:nil];

UIActivityViewController not showing "Open in iBooks" option

I have a problem in my app. After getting some statistics, I generate a PDF file, and I want to show an UIActivityViewController with the options "Open in iBooks" and "Send By Mail" mainly (others like "Open in Dropbox" would be great to).
Well the thing is that before trying to use UIActivityViewController, I was using UIDocumentInteractionController, with the following code:
self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docController.delegate = self;
[_docController presentOpenInMenuFromRect:_openInIBooksButton.bounds inView:self.openInIBooksButton animated:YES];
Where url is a path like /Documents/../statistics.pdf. It worked, it showed a popover with the buttons open in iBooks and open in Dropbox, but not Send by Mail. Now I've changed it with the following code:
NSArray* itemsToShare = [NSArray arrayWithObjects:pdfData, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypeCopyToPasteboard]; //or whichever you don't need
[self presentViewController:activityVC animated:YES completion:nil];
Where pdfData is a NSData object. And it works too, but now it shows the option of sending it by email, but not the iBooks option. I'm going nuts because I don't find the reason of that behavior and I need the two options, iBooks and Mail.
I don't know if it has something to do with the fact that the UIDocumentInteractionController has a path which ends with .pdf and the UIActivityViewController only has a NSData object. But I can't find a solution for that.
Somebody has found that problem before?
Thank you very much.
When you use presentOpenInMenuFromRect:inView:animated: you only get a list of apps that can work with the given file.
What you want to use is presentOptionsMenuFromRect:inView:animated: which gives you the options that you are looking for.

ZXingWidgetController shows a blank screen when loaded

I am using Xcode 4.1, on iOS Simulator 4.3
I have imported the ZXing library into my project as per the instructions in their README.
When I try to load the controller all I see is a white screen with a Cancel button at the bottom. I know the simulator can't take photos but the controller is then supposed to let you choose an image to decode from the photo library. Has anyone had this issue or has any ideas on what is causing it?
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil];
[qrcodeReader release];
widController.readers = readers;
[readers release];
[self presentModalViewController:widController animated:YES];
[widController release];
EDIT: Forgot to mention, there are pictures on the simulator that I loaded already.
but the controller is then supposed to let you choose an image to
decode from the photo library
Where did you see this? It's not in the README or the code.
The widget doesn't provide an image picker backup. The old Barcodes app (found in cpp/iphone/legacy/Barcodes_original) did but the current Barcodes app doesn't. If you need this, you'll have to implement it yourself. The old Barcodes app might be useful as guide, to some extent.

AQGridView iOS Create custom icons (image+label) instead of image

I've just started using AQGridView from Alan Quatermain more specifically, the SpringBoard demo..
The demo shows icons/tiles that consist of a UIImageView. I'd like to know how to use a custom UIView instead so that I can have an icon with text/button underneath.
I'm currently trawling through the code with no real luck in finding how my icons are created.
Any ideas/suggestions would be greatly appreciated..
Cheers.
Check out AQGridViewCell and, specifically, contentView property. This is similar to customizing UITableViewCell.
Have you checked out three20's TTLauncherView?
Although it is for the iPhone you might be able to adopt it for the iPad. It allows for an icon with text underneath. Though you might have to hack it for inserting a custom UIView in place of the image and text.
I found iOSGuy's tutorial helpful when working with TTLauncherView.
And here is an excerpt from iOSGuy's tutorial to show little bit about how it is setup/used.
TTLauncherView* launcherView = [[TTLauncherView alloc]
initWithFrame:self.view.bounds];
launcherView.backgroundColor = [UIColor blackColor];
launcherView.columnCount = 4;
launcherView.pages = [NSArray arrayWithObjects:
[NSArray arrayWithObjects:
[self launcherItemWithTitle:#"Google"
image:#"bundle://safari_logo.png"
URL:#"http://google.com"],
[self launcherItemWithTitle:#"Apple"
image:#"bundle://safari_logo.png"
URL:#"myAppController/myView"]
, nil]
, nil];