How to add UINavigationController to UITabbarController Programatically?


Today I am going to Explain you How to Add UINavigation Controller to UITabbarController.

  • When you add UIViewController to UIWindow Your Application become ViewControllerBase(SingleView) Application.
  • When you add UIViewController to UINavigationController your application become NavigationBased(Master-Detail) Application.
  • When you add UIViewController/UINavigationController to your UITabbarController Your application become Tabbased Application.

so here we are using the same concept that add your Navigation Controller to UITabbarController so you will get Push/Pop effect in UITabbar Controller.

//Initialize tabbar Controller and All Navigation Controllers are added into Tabbar Controller
self.tabbar = [[UITabBarController alloc] init];
NSArray *arrNVControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4, nil];

self.tabbar.viewControllers = arrNVControllers;

Download the sample code from Here


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


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

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.


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:
    [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;
// Implementation file

// Instantiate the action bar in your view controller

- (void)viewDidLoad
    [super viewDidLoad];

    if (self.actionBar == nil) {
        self.actionBar = [SocializeActionBar actionBarWithKey:@"" 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.

Custom Calender For iPad


I have implemented Custom Calender Control for iPad which is bit simple to implement.

Step 1: Add the Listed File into your Project.(I have Provided  all Listed Files.)






Step 2: Now your 70% Task is completed.You need to Integrate the Delegate Methods only.

#pragma mark – CalendarViewDelegate methods
-(void)monthChanged:(CFGregorianDate)currentMonth viewLeftTop:(CGPoint)viewLeftTop height:(float)height{


-(void)beforeMonthChange:(TdCalendarView *)calendarView willto:(CFGregorianDate)currentMonth{


For More info Please check this images.

Here i am attaching the sample code for the same.

Draw Route Between two location

Hi All,

Here I am going to explain you how to draw route using two latitude and Longitude.Here you have to consider if any Sea or River comes between 2 location then route drawing is not possible.

Step 1:Please check the following image for Framework required and predefined classes

if you want you will get all the files with sample code at the end of the post.

Step 2: Import Required files in your ViewController and Provide the 2 different Location’s Latitude and Longitude.Please follow this 2 images accordingly.


You can Grab this code from Here:  

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 {
	[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	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;

	[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	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

You can get the source code from here


FacebookAgent and iPhone/iPad integration

Today most of the applications we build have a common feature: Socialize! One common way to achieve this my integrating Facebook within the app.For iPhone applications FacebookConnect is the only way to integrate facebook social features. Facebook team has developed a sdk for iPhone. A sample code showing the use and integration of Facebook Connect in your application. This is quite simple and also tons of tutorials, forums, e-books and videos are out here on the web.

Objective: Create a simple view based application and publish a feed using FacebookAgent.

1. Download this folder

It also includes facebook connect sdk. So you don’t need to add this sdk elsewhere or even update any project settings for this purpose.

2. Create a new project, name it FacebookAgentTest. Righ click on the project in the XCode and select Add existing files. Add the FacebookAgent Folder to your classes. Check copy the source files.

Add FacebookAgent folder to your project

3.  In the FacebookAgentTestViewController.h, import FacebookAgent.h and implement protocol FacebookAgentDelegate.

@interface FacebookAgentTestViewController : UIViewController {

4. Declare a member variable of type FacebookAgent.

FacebookAgent* fbAgent;

5. Open FacebookAgentTest.m and initialize fbAgent in viewDidLoad method.

fbAgent = [[FacebookAgent alloc] initWithApiKey:@"PLACE YOUR FACEBOOK APPLICATION API KEY"
	fbAgent.delegate = self;

6. Declare an IBAction method in the FacebookAgentTest.h file.


7. Define the above method in FacebookAgentTest.m file.


8. Open FacebookAgentTestViewController.xib and add a button in the view and connect the above method on its touchesUpInside signal.

9. Now just add the following lines in the updateStatus method to publish a feed!

[fbAgent publishFeedWithName:@"Hellow world"
					 captionText:@"how are you?"
			   userMessagePrompt:@"What do you think:"];

This code will first check if the user is logged in. If logged in it will show the feed dialog.
If the user is not logged in already, first the login dialog will be shown, after logging in, the feed dialog will be shown automatically!

But one minute, there is one require method in the FacebookAgentDelegate protocol. So, you need to define this:

- (void) facebookAgent:(FacebookAgent*)agent loginStatus:(BOOL) loggedIn{

Above method is called when the user logs in or logs out of the facebook. If you use any login button which is very likely, you may change the button title here.

10. Try updating your status. For this use this line:

[fbAgent setStatus:@"status from iPhone 1"];

This will first check if the user is logged in. if not logged in, then it will show the login prompt first.
After log in it will check if extended permission is enabled for this app. if not it will show the permission dialog.
Having given the permission, it will change the user status.


11. You need to two more FacebookAgentDelegate method if you want to change status:

- (void) facebookAgent:(FacebookAgent*)agent requestFaild:(NSString*) message{
- (void) facebookAgent:(FacebookAgent*)agent statusChanged:(BOOL) success{

12. Thats all :) Run the app!

You can look into the FacebookAgent.h for more detail. It is well documented. If you still have some question shoot here or drop me mail.
Feel free to use this classes without any restriction but I will appreciate if you let me know in which app you are using it :)

What can be done now using FacebookAgent:
1. Fetch user name:
For this after initialization, set shouldFetchUsernameAfterLogin = YES.

fbAgent.shouldFetchUsernameAfterLogin = YES

and also define the corresponding delegate method:

- (void) facebookAgent:(FacebookAgent*)agent didLoadName:(NSString*) name{
    //use the name

2. Make your own attachment and publish a feed.

// this method has some over loaded versions too
- (void) publishFeed:(NSString*)attachement;

3. Publish feed by passing, name, caption, image and link url.

// this method has some over loaded versions too
 * Let the agent make attachement for you. You just pass the information
- (void) publishFeedWithName:(NSString*)name

4. upload a photo

- (void) uploadPhoto:(NSString*)imageurl;

6. ask for extended permission

- (void) askPermission;

7. login and logout

- (void) login;
- (void) logout;

The delegates also offers some handy callback options like:

 * Must define this method if setStatus is called
 * This method is called when user status is changed either successfully or not
- (void) facebookAgent:(FacebookAgent*)agent statusChanged:(BOOL) success;

 * Must define this method if shouldFetchUsernameAfterLogin is set YES
 * This method is called after the agent fetched facebook profile name
- (void) facebookAgent:(FacebookAgent*)agent didLoadName:(NSString*) name;

 * Must define this method if uploadPhoto is called
 * This method is called after photo is uploaded
- (void) facebookAgent:(FacebookAgent*)agent photoUploaded:(NSString*) pid;

 * Must impement this method if any of the above method is defined
 * This method is called if the agent fails to perform any of the above three actions
- (void) facebookAgent:(FacebookAgent*)agent requestFaild:(NSString*) message;


 * This method is called if after login or logout
- (void) facebookAgent:(FacebookAgent*)agent loginStatus:(BOOL) loggedIn;

Here is the demo project. DONT FORGET TO ADD YOUR key and secret!!



How to Integrate iAd in your Application?


Today I am going to discuss how apple iAd is integrated in our iPhone/iPad Native Application.It’s really a very simple task.I am dividing this task in 3 simple steps.

Step 1:

1.import iAd Framework to the Application.

2.Provide #import <iAd/iAd.h> in the particular controller where you want to show your Add.

3.Provide it’s delegate UIViewController <ADBannerViewDelegate>

4.Provide one  view to that particular ViewController.Assume I have taken

@property (weak, nonatomic) IBOutlet UIView *contentView;

Step 2:

Allocate it in ViewDidLoad method

– (void)viewDidLoad
_bannerView = [[ADBannerView alloc] init];
_bannerView.delegate = self;

[super viewDidLoad];
[self.view addSubview:_bannerView];

step 3:

Provides it’s delegate methods which i have mention bellowed.

– (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
_bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
} else {
_bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
[self layoutAnimated:duration > 0.0];

– (void)bannerViewDidLoadAd:(ADBannerView *)banner
[self layoutAnimated:YES];

– (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
[self layoutAnimated:YES];

– (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave

return YES;

– (void)bannerViewActionDidFinish:(ADBannerView *)banner

– (void)layoutAnimated:(BOOL)animated
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
_bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
} else {
_bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;

CGRect contentFrame = self.view.bounds;
CGRect bannerFrame = _bannerView.frame;
if (_bannerView.bannerLoaded) {
contentFrame.size.height -= _bannerView.frame.size.height;
bannerFrame.origin.y = contentFrame.size.height;
} else {
bannerFrame.origin.y = contentFrame.size.height;

[UIView animateWithDuration:animated ? 0.25 : 0.0 animations:^{
self.contentView.frame = contentFrame;
[self.contentView layoutIfNeeded];
_bannerView.frame = bannerFrame;

and your Advertisement is ready.

You can take the source code from Here.

(In File Option click on Download Original)

How to use UIAlertView in your Application?

Hello Friends now we are moving forward with some development side.Today I am going to explain usage of UIAlertView.

Here is a example for this:

UIAlertView *simpleAlert = [[UIAlertView alloc] initWithTitle:@”Simple Alert” message:@”Alert’s message” delegate:self cancelButtonTitle:@”OK” otherButtonTitles:nil];

[simpleAlert show];

[simpleAlert release];

Here simpleAlert is an object for UIAlertView class.Using initWithTitle we can set the title for Alert and with message:@”” we can set the appropriate message for it.We have to set the delegate for it and provide the cancelButtonTitle here OK is provided here.

using [simpleAlert show] alert is prompted and user can get the Alert to his screen.using release keyword we have freed the memory which we have used using alloc keyword.

Grab the code from Here

In File Menu Click on Download Original tab for Grab this Code.