How to use Socialize in your iPhone/iPad native application?


Hi,

I have integrate Socialize in one of my sample code and believe me it’s amazing.it’s far better than any other sharing media.just visit this web site initially.http://www.getsocialize.com/.

It includes Email,Facebook and Twitter.I have Integrated Email and Twitter and working on Facebook as well.I am going to Explain you how to integrate it in your application.

Step 1: Click Here

Step 2: Choose 1 st option  Register and get your API keys.Once you have your API Key’s with you then follow step 3.

Step 3: When you click on DownLoad SDK for iOS you will get Framework for Integration.

Step 4: Add Socialize framework to your Application with Copy option selected as shown in the image.

step 5:Add Required Framework as shown below.

CoreLocation.framework,MapKit.framework,MessageUI.framework,QuartzCore.framework,CoreGraphics.framework

step 6: Set other Linker Flag as shown below.

step 7: Import Header and Set up your Socialize Keys like this.

//import the socialize header
#import <Socialize/Socialize.h>

#pragma mark
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
    // set the socialize api key and secret, register your app here: http://www.getsocialize.com/apps/
    [Socialize storeConsumerKey:@"SOCIALIZE_CONSUMER_KEY"];
    [Socialize storeConsumerSecret:@"SOCIALIZE_CONSUMER_SECRET"];

    //your application specific code

    return YES;
}

Step 8: Include Socialize in your App!

// Header file

// Store the action bar in a property on your view controller

#import <Socialize/Socialize.h>

@interface CreateActionBarViewController : UIViewController
@property (nonatomic, retain) SocializeActionBar *actionBar;
@end
// Implementation file

// Instantiate the action bar in your view controller

- (void)viewDidLoad
{
    [super viewDidLoad];

    if (self.actionBar == nil) {
        self.actionBar = [SocializeActionBar actionBarWithKey:@"http://www.example.com/object/1234" name:@"Something" presentModalInController:self];
        [self.view addSubview:self.actionBar.view];
    }
}

Now your App is ready to display Socialize bar.Here I am giving you the Sample code with Twitter integration and update it once it get completed with Facebook as well.

Advertisements

How to take screenshots within your Application.


iPhone / iPod touch allows you to make screenshots (saves the contents as an image) by pressing both home and power button, although many users don’t know this functionality. If you go to your camera roll or sync photos with your computer, every screenshot you make is an image 320 x 480 px.

Today I will show you how to make a screenshot of arbitrary size using Quartz. What does arbitrary size mean? Well you can not only save the smaller part of your screen, but, if you for example have bigger view than 320×480 px you can save it all, not only the visible part.

Before you start, you have to add the QuartzCore framework to the project.

#import <QuartzCore/QuartzCore.h>

You can add this line in either header (.h) or implementation file (.m).

Now it’s time to add the method which will make a screenshot and explain how it works:

-(void)saveToCameraRoll {
	UIGraphicsBeginImageContext(self.view.bounds.size);
	[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	UIImageWriteToSavedPhotosAlbum(viewImage, self, nil, nil); 

	/* 
	flashView.alpha = 1;
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:0.5];
	flashView.alpha = 0;
	[UIView commitAnimations];
	UIAlertView *alert= [[UIAlertView alloc] initWithTitle:nil message:@"Photo saved to your camera roll" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
	[alert show];
	[alert release];
	*/
}

I’ve implemented the saveToCameraRoll method were first five lines do everything you need. It’s quite difficult to discuss it, as long as I never mentioned about Quartz drawingcontextslayers… But, first line creates the context of our view (UIViewController’s self.view) size. Using that context’sframe (it’s not frame properly speaking) it contents is rendered (2nd line) and saved to anviewImage. 4th line is closing the context as we do not need it anymore, and the 5th line putsviewImage to the Camera Roll.

How about the part in the comment ( /* and */ )? Well it’s my idea how to copy the animation iPhone uses while making the screenshot using home and power buttons. I created the flashView – simple white view of the same size of my self.view most time 100% transparent. When the userdecides to create a screenshot using a button I provided in the application, flashView become visible and during half a second it’s transparent again. And the alert to inform what has just happen.

Please remember that above method saves the whole self.view and all it’s subviews. So whatever is a subview of self.view will be saved as well. You can change the alpha property of anything you don’t want to save and reveal what’s behind it, and after screenshot was made bring alpha to normal. While making a screenshot as long as it will be one procedure – one task user won’t see any changes in interface. Example:

-(void)saveToCameraRoll {	topView.alpha = 0;

	UIGraphicsBeginImageContext(self.view.bounds.size);
	[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	UIImageWriteToSavedPhotosAlbum(viewImage, self, nil, nil); 
	topView.alpha = 1;

}

As always (don’t thank me) I provided an sample project. It alows you to make screenshot of whole iPhone screen (320 x 480 px), only central part (320 x 240 px) and again the whole iPhone screen without button on the bottom.

 

Thanks goes to http://chris-software.com/

You can get the source code from here