Posts

Showing posts from December, 2012

PayPal SDK for iOS

PayPal SDK for iOS Another day another dollar. After spending half a day, well I should say wasting half a day I've finally figured out how to add  PayPal's   SDK  for  iOS . I'm currently using  XCode  4. I will break it down into steps so hopefully this will help others! 1.)  SDK  Download. - First you have to download the  PayPal   iOS   SDK  from  here . 2.) "Adding the Files" - Control Click on your project.xcode file and chose "Add files to project" (or chose File->"Add files to Project"). - Navigate to where you had saved your downloaded  PayPal   SDK  on disk. - You will find a folder named "Library" which contains 11 header files, as well as a static library named " libPayPalMPL .a". - Select all of these files and check the "Copy items into destination group's folder (if needed)  check box . - Now before you build your project you have to add additional libraries. 

Crop Image

Crop the image //Croping start from x=0; y=0; and till width=125 and height=128; UIImage * image = imageView . image ; CGRect cropRect = CGRectMake ( 0 , 0 , 125 , 128 ); CGImageRef imageRef = CGImageCreateWithImageInRect ([ image CGImage ], cropRect ); [ imageView setImage :[ UIImage imageWithCGImage : imageRef ]];   CGImageRelease ( imageRef ); Mask Image - ( UIImage * ) maskImage : ( UIImage * ) image withMask : ( UIImage * ) maskImage {   CGImageRef maskRef = maskImage.CGImage;   CGImageRef mask = CGImageMaskCreate ( CGImageGetWidth ( maskRef ) , CGImageGetHeight ( maskRef ) , CGImageGetBitsPerComponent ( maskRef ) , CGImageGetBitsPerPixel ( maskRef ) , CGImageGetBytesPerRow ( maskRef ) , CGImageGetDataProvider ( maskRef ) , NULL , false ) ;   CGImageRef masked = CGImageCreateWithMask ( [ image CGImage ] , mask ) ; return [ UIImage imageWithCGImage : masked ] ;   }

How to restrict user to enter character in phone UITextField

When you want user to enter only number (like in case of mobile number) then you can restrict using this 1. Put a macro before @implementation        #define NUMERIC @"1234567890" 2. textField DelegateMethod       - ( BOOL ) textField :( UITextField *) textField shouldChangeCharactersInRange :( NSRange ) range replacementString :( NSString *) string { NSCharacterSet * unacceptedInput = nil ; if ( textField == self . phoneTextField ) { unacceptedInput = [[ NSCharacterSet characterSetWithCharactersInString : NUMERIC ] invertedSet ]; } return ([[ string componentsSeparatedByCharactersInSet : unacceptedInput ] count ] <= 1 ); }