Sharing is indeed one of
the important concepts when it comes to mobile computing people love to share
about the recent events in their life.
Apple in iOS6 has introduced a
class which will help the developers to give multiple options to the users for
sharing.
The new class introduced
by apple is called UIActivityViewController which will help the developers to
do this.
This class makes
use of the account settings for various social networks or mail present in your
iOS devices.
So let’s see how to make
use of this class
Step 1: Open Xcode and
create a single view based application, in the viewController.xib add the
object of the UIButton class
Step 2: Declare the
IBAction method in the viewcontroller.h file and connect it with the UIButton
present in the XIB
Step 3: Let’s have a look
at the code part of the IBAction method in the view controller.m file.
Code Explanation: In the
above code we have to create the object of the UIActivityIndicatorViewController
and what so every data you want to post you have to provide it in an array to
it.
Step 4: All set and done
now run the application and touch the button and when you do you will get the
following output.
As i have said earlier it makes use of the accounts that the user has already set up with the iOS device so currently i have not set up any settings for facebook and if i select facebook for sharing then i get a message which asks me to set up my facebook account in the settings option.
If you want to attach an image for sharing then you need to add the image object in the array and leave everything as it is.
Now when you again run the application then you will get the following result
The last part pending is how to tackle completion of a particular posting event by this controller,
Now when you post using any of the social media then you will receive a pop up which would describe whether the posting was successful or not and in the console you may check which media you have used.
You may download the
source code from here.
I hope that this post has
helped you out in using the UIActivityIndicatorViewController, in case if you
are having any questions or queries then do let me know via mail or via
comments.
Until then Happy iCoding
and have a great Day.
I liked this post very much as it has helped me a lot in my research and is quite interesting as well. Thank you for sharing this information with us.
ReplyDeleteDecision Making
But how can you run a IBAction from your viewController from the UIActivityViewController... i open my UIActivityViewController in lets call it MYviewController in that i have a IBAction called inApp.
ReplyDeletehow do i run that ?