Posts

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 l...

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 ); }

Nice tutorial

Nice One http://rypress.com/tutorials/objective-c/ TableView DragAndDrop row from one table to other http://www.scott-sherwood.com/ios-5-drag-and-drop-between-uitableviews/ Sample github TableViewCell http://code.tutsplus.com/tutorials/ios-sdk-crafting-custom-uitableview-cells--mobile-15702 Animation http://blog.devedup.com/index.php/2010/03/03/iphone-animate-an-object-along-a-path/ FlowCover -> Vertical Scrolling View http://www.chaosinmotion.com/flowcover.html Creating Static Libraries For iO S http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/ http://www.stanford.edu/class/cs193p/cgi-bin/drupal/downloads-2011-fall http://rypress.com/ AutoLayout http://blogs.captechconsulting.com/blog/raymond-robinson/ios-6-tutorial-series-dynamic-interfaces-auto-layout

Flip The image

This is to flip the image. UIImage * flipped = [ UIImage imageWithCGImage : imag . CGImage scale : 1.0 orientation : UIImageOrientationDown ];

The simplest way to resize an UIImage.

+ ( UIImage *) imageWithImage :( UIImage *) image scaledToSize :( CGSize ) newSize { //UIGraphicsBeginImageContext(newSize); UIGraphicsBeginImageContextWithOptions ( newSize , NO , 0.0 ); [ image drawInRect : CGRectMake ( 0 , 0 , newSize . width , newSize . height )]; UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext (); return newImage ; } StackOveFlow  Link

Show hidden files Mac OS X 10.7 Lion and 10.8 Mountain Lion

To Show hidden files/folders in finder windows: Open Finder. Open the Utilities folder. Open a terminal window. Copy and paste the following line in terminal: >> defaults write com.apple.finder AppleShowAllFiles TRUE >> killall Finder Line 1:  command will show all hidden files and folder. Line 2:    command is to re-launch the Finder window. You should find you will now be able to see any hidden files or folders. Revert Back :: One you are done, perform the steps above however, replace the terminal command in step 4 with: >> defaults write com.apple.finder AppleShowAllFiles FALSE >> killall Finder