Thursday, February 17, 2011

Add a button on navigationbar ?


UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(flipAction:) forControlEvents:UIControlEventTouchUpInside];
flipButton = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
self.navigationItem.rightBarButtonItem = flipButton;

Wednesday, February 16, 2011

How to send Email with HTML body ?

Download the link

How to send Email with attachment

Download the link

Full Proof Email Composer in iPhone .

This is a full proof method to embed email interface in your app. It handles the scenario when you don't have email feature on your device or you don't have any email account set up on your device.
This piece of code also shows you how to attach pdfs as well.




UIButton *emailPdfButton=[[UIButton alloc]initWithFrame:CGRectMake(10, 10, 100, 40)];
[emailPdfButton setBackgroundColor:[UIColor greenColor]];
[emailPdfButton addTarget:self action:@selector(emailPdf:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:emailPdfButton];



-(IBAction)emailPdf:(id)sender{
    
    //find if email exists
    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if (mailClass != nil)
    {        
        //find atleast one email account is set up
        if([MFMailComposeViewController canSendMail])
        {
            MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
[controller setMessageBody:nil isHTML:YES];
[controller setSubject:@"Subject."];
[controller setMessageBody:@"Body Of Email." isHTML:NO];
[controller setToRecipients:[NSArray arrayWithObjects:nil,nil]];
[controller addAttachmentData:[NSData dataWithContentsOfFile:[self GetPdfFilePath]] mimeType:@"application/pdf" fileName:@"file.pdf"];
controller.navigationBar.tintColor = [UIColor grayColor];
[controller setMailComposeDelegate:self];
[self presentModalViewController:controller animated:YES];
[controller release];
        
        }
        else
        {
            //display the alert that set up an email account
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please set up your email account on device." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
            [alertView release];
        }
    }
    else
    {
        //display the alert that email account not available
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"No valid email account available on device." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
        [alertView release];
    
    }
    
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
    
    
    
    NSString *message = @"";
    switch (result) {
         
        case MFMailComposeResultCancelled:
            message = @"Email Canceled";
            break;
        case MFMailComposeResultSaved:
            message = @"Email Saved";
            break;
        case MFMailComposeResultSent:
            message = @"Email Sent";
            break;
        case MFMailComposeResultFailed:
            message = @"Email Failed";
            break;
        default:
            message = @"Email Not Sent";
            break;

            
    }
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
    [alertView release];
    [controller dismissModalViewControllerAnimated:YES];
}



How to send SMS with body defined by user ?

Download the Code

How to send SMS in iPhone ?

Download the code

Thursday, February 10, 2011

How to write formatted code in your blog


Now you can add the code as following

Way 1:


Insert the Special code here

Wednesday, February 9, 2011

Display UIAlertView in iPhone

Alertview with only 1 button.







































 Alertview with yes and no button.






































 Alertview with more than 2 buttons.











































<script type="syntaxhighlighter" class="brush: csharp">
script>


 You can download the complete code to check out the functions in depth.


Download the Code

How to take screenshot on your mac machine

Ever wondered how to take capture the screen of your macbook or mac machine's desktop ?

Well. all you got to do is press Cmd+Shift+ 3 . This will capture whole screen and save the screenshot on your desktop as  Screen shot_date_time.png


If you want to capture only selected area of your macbook screen , then you need to press Cmd+Shift+4. This will bring a crosswire on your screen you can just pick one location on your screen to start and end it where your area of interest ends !




How to change _MyCompanyName_ in header of the XCode project files

If you are wondering how to change the username and company name of the header of the files being created in your XCode then you are at the right place !

//
//  PrintingAppDelegate.h
//  Printing
//
//  Created by ABC on 10/02/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

It looks like above and now I want to change __MyCompanyName__ to say "Reetu Inc." then I just need to do following step and hence all the new files I create in the project will have updated name and company name.

Steps:
1. Go to XCode > Project > Edit Project Settings




























2.  In Project Setting window, Select General Tab as shown below then go to Organization Name: as highlighted area in the screenshot below. Change it to whatever name you want. I have changed it to Reetu Inc.






































3. Now when you will create a new file, it will display the updated company name !

New file in Xcode with updated _MyCompanyName_




 


  










Sunday, February 6, 2011

How to remove an application from your facebook account ?

You are wandering around to find out how to remove twitter feeds from your facebook account because you feel like you are overpopulating your post on facebook ?
Here are the steps with screenshots.

Go to  Account> Privacy Setting. You will see something like screenshot below:
 Hit the edit button in front of Apps you use, you will see all the apps you are using with remove button in front of all  of them. If you press 'x' button , you will see something like shown below:





How to add "Like" button on your blogger's post ?

Well if you are a blogger and an FB user then it would be a smart option for you to start utilizing their power together in lesser time. Today I am gonna explain how you can add "LIKE" button power to your  blog !
1.First you need to go to your blog and in the Settings, Go to Design Tab >> Edit HTML Tab. You will see as shown in the image on the left.


2. You need to check the option which says Expand Widget Templates.





 3. Then you need to find the div section in your template where it says "post-header-line-1"




4.Then you post following lines in that div section.< iframe allowTransparency='true' expr:src='"http://www.facebook.com/plugins/like.php?href=" + data:post.url + "&layout=standard&show_faces=false&width=100&action=like&font=arial&colorscheme=light"' frameborder='0' scrolling='no' style='border:none; overflow:hidden; width:450px; height:40px;'/>





5. And you save your updated template. Now when you view your blog, you will the mighty LIKE button on each posting of your blog as shown in the image below !


Ok. thats it ! :)