Saturday, 25 February 2012

ImageView gallary + rotation + zoom in/out in iphone

imagepicker view & gallery
http://www.zimbio.com/iPhone/articles/1109/Picking+Images+iPhone+SDK+UIImagePickerController

//for image rotation and zoom in /out
http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/
https://github.com/elc/iCodeBlogDemoPhotoBoard
Gridview in iphone
http://www.iphonedevsdk.com/forum/iphone-sdk-development/63512-zzgridview-uitableview-image-grid-view-sections-support.html

move anything like vibration in iphone

move anything like vibration in iphone

http://iphone.zcentric.com/2008/09/23/add-a-wiggle/

smiley & emoji symbols code + iphone

smiley & emoji  symbols code

http://www.easyapns.com/category/just-for-fun

Image wingling like vibration + iphone

Image wingling like vibration
http://iphone.zcentric.com/2008/09/23/add-a-wiggle

Scrolling + paging image demo + iphone

Scrolling + paging image demo

http://code.davidjanes.com/blog/2009/09/26/uipagecontrol-uiscrollview/

Friday, 24 February 2012

zoom in /out + button with rotate by + - Buttons + iphone

#define degreesToRadians(x) (M_PI * x / 180.0)
#define zoomed 0.01
-(IBAction)resizeImageview:(id)sender{
   
    if([sender tag]==1){
        // holderView.frame=CGRectMake(x+3, y+4, width-6,height-8);
        holderView.transform = CGAffineTransformScale(holderView.transform, 1-zoomed, 1-zoomed);
       
    }
    else if([sender tag]==2){
        //holderView.frame=CGRectMake(x-3, y-4, width+6,height+8);       
        holderView.transform = CGAffineTransformScale(holderView.transform, 1+zoomed, 1+zoomed);
    }


}
-(IBAction)rotateImageView:(id)sender{
    if ([sender tag]==3) {
        holderView.transform = CGAffineTransformRotate(holderView.transform, degreesToRadians(-10));
       
    }
    else if([sender tag]==4){
        holderView.transform = CGAffineTransformRotate(holderView.transform, degreesToRadians(10));
       
    }   
}

epub reader example + iphone

pub reader example

https://github.com/st3fan/iphone-bookreader

UIImageView Rotate, Move and Zooming and also for different example + iphone

UIImageView Rotate, Move and Zooming and also for different example


http://w2om.com/uiimage-rotate-move-and-zooming/

image cropping ,transparency etc + iphone

http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

Zoom inout or pinch in pinch out of uiimageview +iphone

http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/

Simple animation+ iphone

Simple animation

http://www.edumobile.org/iphone/iphone-programming-tutorials/moveimage-in-iphone/

Text to Speech with flite + IPHONE

Api url
https://bitbucket.org/sfoster/iphone-tts/src
//For code it
https://bitbucket.org/sfoster/iphone-tts/

Checking white space and Trimming specific character in iphone

#define allTrim( anyobject ) [anyobject
 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet] ]

NSString *stringname = @"   ";
if ( [allTrim( stringname ) length] == 0 ) NSLog(@"Is empty!");

Accessing specific folder files in iphone app

Accessing specific folder files
1. add folder with the second radio button
2. it is located at anyname.app/yourfolder


NSString *bundleRoot1 = [[NSBundle mainBundle] resourcePath];
    bundleRoot1=[bundleRoot1 stringByAppendingString:@"/Images"];
    NSArray *dirContents1 = [[NSFileManager defaultManager] directoryContentsAtPath:bundleRoot1];
    NSLog(@"dirContents1 %@",dirContents1);
   
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:[dirContents1 objectAtIndex:0]]]];

Getting particular named images from the project + iphone

NSMutableArray *any=[[NSMutableArray alloc] init];
    NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
    NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:bundleRoot];
    for (NSString *tString in dirContents) {
        if ([tString hasPrefix:@"Fire Type1"] && [tString hasSuffix:@".png"]) {
           
            [any addObject:tString];
           
        }
    }
    NSLog(@"%@",any);

Border of the imageview in iphone

[imageView.layer setBorderColor: [[UIColor redColor] CGColor]];
    [imageView.layer setBorderWidth: 2.0];

drawing the rectangle lines on the any object + iphone

- (void)drawRect  {
    UIGraphicsBeginImageContext(self.view.frame.size);
   
    CGContextRef currentContext = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(currentContext, 3.0); //or whatever width you want
    CGContextSetRGBStrokeColor(currentContext, 0.0, 0.0, 0.0, 1.0);
   
    CGRect myRect = CGContextGetClipBoundingBox(currentContext);
    //printf("rect = %f,%f,%f,%f\n", myRect.origin.x, myRect.origin.y, myRect.size.width, myRect.size.height);
   
    CGContextStrokeRect(currentContext, myRect);
    UIImage *backgroundImage = (UIImage *)UIGraphicsGetImageFromCurrentImageContext();
    UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [myImageView setImage:backgroundImage];
    [self.view addSubview:myImageView];
    [backgroundImage release];
   
    UIGraphicsEndImageContext();
}

mic Detection program +iphone

http://mobileorchard.com/tutorial-detecting-when-a-user-blows-into-the-mic/

SCListner class + iphone

SCListner class
https://github.com/stephencelis/sc_listener

Send mail from the iphone ipad

-(IBAction)sendEmail
{
   
    //disappear=YES;
    if([MFMailComposeViewController canSendMail] == false) {
        UIAlertView *view = [[UIAlertView alloc] initWithTitle:@"Error" message:@"The device cannot currently send email." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [view show];
        [view release];
        return;
    }
    else{
        Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
        if (mailClass != nil)
        {
            // We must always check whether the current device is configured for sending emails
            if ([mailClass canSendMail])
            {
                [self displayComposerSheet];
            }
            else
            {
                [self launchMailAppOnDevice];
            }
        }
        else
        {
            [self launchMailAppOnDevice];
        }
    }
   
}
-(void)displayComposerSheet
{
   
    MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
    mailView.mailComposeDelegate = self;
    //SharedManager *sm = [SharedManager sharedInstance];
    [mailView setSubject:@"Hello from "];//[sm.text substringToIndex:20]];
   
    [mailView setMessageBody:@"You can know more from this url!" isHTML:YES];
   
    NSData *attachmentData = UIImageJPEGRepresentation(getImg, 1.0);
    UIImage *image=getImg;
    [mailView addAttachmentData:attachmentData mimeType:@"image/png" fileName:[NSString stringWithFormat:@"%@",image]];
     [self presentModalViewController:mailView animated:YES];
    [mailView release];
   
}


#pragma mark -
#pragma mark Workaround

// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{    
    MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
    mailView.mailComposeDelegate = self;
    [mailView setSubject:@"Hello from  "];    
    [mailView setMessageBody:@"You can know more from this url!" isHTML:YES];
   
    NSData *attachmentData = UIImageJPEGRepresentation(getImg, 1.0);
    UIImage *image=getImg;
    [mailView addAttachmentData:attachmentData mimeType:@"image/png" fileName:[NSString stringWithFormat:@"%@",image]];
    [self presentModalViewController:mailView animated:YES];
    [mailView release];
   
   
   
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    // Dismiss Mail View
    [self dismissModalViewControllerAnimated:YES];
   
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail send canceled");
            self.navigationController.navigationBar.hidden =YES;
            break;
        case MFMailComposeResultSent:
            [appDel showAlert:@"Mail sent successfully." message:@"Success"];
            NSLog(@"Mail send successfully");
            break;
        case MFMailComposeResultSaved:
            [appDel showAlert:@"Mail saved to drafts successfully." message:@"Mail saved"];
            NSLog(@"Mail Saved");
            break;
        case MFMailComposeResultFailed:
            [appDel showAlert:[NSString stringWithFormat:@"Error:%@.", [error localizedDescription]] message:@"Failed to send mail"];
            NSLog(@"Mail send error : %@",[error localizedDescription]);
            break;
        default:
            break;
    }
}

Send sms from the iphone ipad + iphone

- (void)sendSMS
{
    if ([MFMessageComposeViewController canSendText])
    {
        MFMessageComposeViewController *messageView = [[MFMessageComposeViewController alloc] init];
        messageView.messageComposeDelegate = self;
       
         [self presentModalViewController:messageView animated:YES];
        [messageView release];
    }
    else {
        [appDel showAlert:@"Oops" message:@"You can't send message"];
    }
   
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
  //  SMS.hidden = NO;
    switch (result)
    {
        case MessageComposeResultCancelled:
           // SMS.text = @"Result: canceled";
            NSLog(@"Result: canceled");
            break;
        case MessageComposeResultSent:
         //   SMS.text = @"Result: sent";
            NSLog(@"Result: sent");
            break;
        case MessageComposeResultFailed:
          //  SMS.text = @"Result: failed";
            NSLog(@"Result: failed");
            break;
        default:
         //   SMS.text = @"Result: not sent";
            NSLog(@"Result: not sent");
            break;
    }
   
    [self dismissModalViewControllerAnimated:YES];
   
}

memory warningissues + iphone

//For memory warning issues
http://akosma.com/2009/01/28/10-iphone-memory-management-tips/

imageview animation like crossDissolve + iphone

#import <QuartzCore/QuartzCore.h>
...
imageView.image = [UIImage imageNamed:(i % 2) ? @"3.jpg" : @"4.jpg"];

CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;

[imageView.layer addAnimation:transition forKey:nil];

Image Cropping + iphone

- (UIImage*)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect
{
    CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect);
    UIImage *cropped = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);   
   
    return cropped;
}

TwitPic + iphone

http://www.techotopia.com/index.php/An_Example_iPhone_iOS_5_TWTweetComposeViewController_Twitter_Application

Lazy loading of tableview in iphone

/Lazy loading of tableview in iphone

http://kshitizghimire.com.np/lazy-loading-custom-uitableviewcell/

Dropdown list in iphone

http://kshitizghimire.com.np/dropdown-in-iphoneipad/

paint in iphone

paint in iphone

http://www.bogotobogo.com/XcodeSDK-Chapter11.html

uiimage+extra classes for the brightness,contrast,sepia and more + iphone

//For the uiimage+extra classes for the brightness and contrast

https://github.com/coryleach/UIImageAdjust

//For the uiimage sepia and more

https://github.com/Nyx0uf/NYXImagesUtilities/tree/master/Categories

mirrored image orientation + iphone

if (mirrorOn==NO) {
       rgbImg.image = [UIImage imageWithCGImage:rgbImg.image.CGImage scale:rgbImg.image.scale orientation:UIImageOrientationUpMirrored];
       mirrorOn=YES;

    }
   else if (mirrorOn==YES) {
       mirrorOn=NO;
       rgbImg.image = [UIImage imageWithCGImage:rgbImg.image.CGImage scale:rgbImg.image.scale orientation:UIImageOrientationUp];

    }

Black & White of the image + iphone

UIImage *originalImage = rgbImg.image; // this image we get from UIImagePickerController
    CGColorSpaceRef colorSapce = CGColorSpaceCreateDeviceGray();
    CGContextRef context = CGBitmapContextCreate(nil, originalImage.size.width, originalImage.size.height, 8, originalImage.size.width, colorSapce, kCGImageAlphaNone);
    CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
    CGContextSetShouldAntialias(context, NO);
    CGContextDrawImage(context, CGRectMake(0, 0, originalImage.size.width, originalImage.size.height), [originalImage CGImage]);
    CGImageRef bwImage = CGBitmapContextCreateImage(context);
    CGContextRelease(context);
    CGColorSpaceRelease(colorSapce);
    rgbImg.image = [UIImage imageWithCGImage:bwImage]; // This is result B/W image.
    CGImageRelease(bwImage);

Invert of any object in iphone

UIGraphicsBeginImageContext(rgbImg.image.size);
    CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy);
    UIImage * image=rgbImg.image;
    [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
    CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference);
    CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor);
    CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, image.size.width, image.size.height));
    rgbImg.image= UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

Touch and Erase in uiimageview in iphone

http://www.iphonedevsdk.com/forum/iphone-sdk-development/13064-how-draw-transparent-stroke-anyway-delete-some-part-uiimage-cg.html

glow of the line + iphone

/*float glowWidth = 10.0;
     float colorValues[] = { 0, 0, 1, 1.0 };
     CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
     CGColorRef glowColor = CGColorCreate( colorSpace, colorValues );
     CGContextSetShadowWithColor( c, CGSizeMake( 0.0, 0.0 ), glowWidth, glowColor );*/

page curl effect from left to right & vice versa + iphone

page curl effect from left to right & vice versa
https://github.com/jemmons/PageCurl

soap parsing demo + iphone

http://www.icodeblog.com/2008/11/03/iphone-programming-tutorial-intro-to-soap-web-services/

Bluring to imageview + iphone

-(UIImage*)imageWithBlurAroundPoint:(CGPoint)point {
    CGRect             bnds = CGRectZero;
    UIImage*           copy = nil;
    CGContextRef       ctxt = nil;
    CGImageRef         imag = rgbImg.image.CGImage;
    CGRect             rect = CGRectZero;
    CGAffineTransform  tran = CGAffineTransformIdentity;
    int                indx = 0;
   
    rect.size.width  = CGImageGetWidth(imag);
    rect.size.height = CGImageGetHeight(imag);
   
    bnds = rect;
   
    UIGraphicsBeginImageContext(bnds.size);
    ctxt = UIGraphicsGetCurrentContext();
   
    // Cut out a sample out the image
    CGRect fillRect = CGRectMake(point.x - 10, point.y - 10, 20, 20);
    CGImageRef sampleImageRef = CGImageCreateWithImageInRect(rgbImg.image.CGImage, fillRect);
   
    // Flip the image right side up & draw
    CGContextSaveGState(ctxt);
   
    CGContextScaleCTM(ctxt, 1.0, -1.0);
    CGContextTranslateCTM(ctxt, 0.0, -rect.size.height);
    CGContextConcatCTM(ctxt, tran);
   
    CGContextDrawImage(UIGraphicsGetCurrentContext(), rect, imag);
   
    // Restore the context so that the coordinate system is restored
    CGContextRestoreGState(ctxt);
   
    // Cut out a sample image and redraw it over the source rect
    // several times, shifting the opacity and the positioning slightly
    // to produce a blurred effect
    for (indx = 0; indx < 5; indx++) {
        CGRect myRect = CGRectOffset(fillRect, 0.5 * indx, 0.5 * indx);
        CGContextSetAlpha(ctxt, 0.2 * indx);
        CGContextScaleCTM(ctxt, 1.0, -1.0);
        CGContextDrawImage(ctxt, myRect, sampleImageRef);
    }
   
    copy = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
   
    return copy;

}

line drawing and erasing write it between the touch moved + iphone

UITouch *touch = [touches anyObject];   
    CGPoint currentPoint = [touch locationInView:self.colorView];
      //currentPoint.y -= 20;
        if (appDelegate.iphoneIpad==1) {
            drawPencil.frame=CGRectMake(currentPoint.x+5,currentPoint.y-30,drawPencil.frame.size.width,drawPencil.frame.size.height);       
           
        }
        else{
            drawPencil.frame=CGRectMake(currentPoint.x+10,currentPoint.y-80,drawPencil.frame.size.width,drawPencil.frame.size.height);       
           
        }
       
        if (eraseDrawImg==NO) {
                //For Drawing of line....
           
                //drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
                UIGraphicsBeginImageContext(self.colorView.frame.size);
                [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
                CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
                CGContextSetLineWidth(UIGraphicsGetCurrentContext(), eraseSize);
                
                    CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(),color);
               
                CGContextBeginPath(UIGraphicsGetCurrentContext());
                CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
                CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
                CGContextStrokePath(UIGraphicsGetCurrentContext());
                drawImage.image=UIGraphicsGetImageFromCurrentImageContext();
                          
                UIGraphicsEndImageContext();  
                
            } 
            else{
                //For Erasing of Drawn line....

                UIGraphicsBeginImageContext(self.colorView.frame.size);
                [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
                CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast);
                CGContextSetLineWidth(UIGraphicsGetCurrentContext(), eraseSize);
                CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
                CGContextAddArc(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y, eraseSize, 0.0, 2*M_PI, 0);//, 50, 50, 50, 0.0, 2*M_PI, 0);
                CGContextClip(UIGraphicsGetCurrentContext());
                CGContextClearRect(UIGraphicsGetCurrentContext(),self.colorView.frame);

                CGContextBeginPath(UIGraphicsGetCurrentContext());
                CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
                CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, eraseSize,eraseSize));
                
                CGContextStrokePath(UIGraphicsGetCurrentContext());
                drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
                UIGraphicsEndImageContext();
            }           
           // NSLog(@"%d",imageTag);
         NSLog(@"%@",lineArray);
        lastPoint = currentPoint;
   
        mouseMoved++;
   
    if (mouseMoved == 10) {
        mouseMoved = 0;
        }
    }

pdf demos + iphone

http://pspdfkit.com/

sorting of array into alphabetic order + iphone

sorting of array into alphabetic order
wordArray = [[wordArray sortedArrayUsingSelector:
                       @selector(compare:)] mutableCopy];

Check the network is available or not + Iphone

checking of network
-(BOOL)checkNetworkConnection{
    NSString *connectingString=[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://google.com"]];
    if ([connectingString length]==0) {
        NSLog(@"not connected");
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Error" message:@"Network is not available " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
        netWork=YES;
    }
    else {
        netWork=NO;
    }
   
    [connectingString release];
    return netWork;
}

Paint demo + iphone

paint demo
http://code.google.com/p/paintboardiphone/downloads/list
http://pastebin.com/9dKPHt6R
http://www.iphonedevsdk.com/forum/iphone-sdk-development/13064-how-draw-transparent-stroke-anyway-delete-some-part-uiimage-cg.html

Getting UUID in iphone

CFUUIDRef cfuuid = CFUUIDCreate (kCFAllocatorDefault);
    NSString *uuid = (NSString *)CFUUIDCreateString (kCFAllocatorDefault, cfuuid);
    CFRelease (cfuuid);
    NSLog(@"%@",uuid);

IN- App and MKStoreManager of the app + iphone

http://www.sixtemia.com/journal/2009/08/12/using-store-kit-framework/

paint app reference + iphone

http://itunes.apple.com/us/app/xpaint/id388881325?mt=8
http://itunes.apple.com/us/app/doodle-touch/id398904512?mt=8

CiFaceDetection + iphone

http://maniacdev.com/2011/11/tutorial-easy-face-detection-with-core-image-in-ios-5/

writing to the xml file + iphone

NSString *fromNumber;
    NSString *toNumber;
    NSString *msg;
   
   
    NSString *tempString = @"<?xml version=""1.0"" encoding=""UTF-8""?>";
    NSString *strXmlNode = [[NSString alloc] initWithFormat:@"%@<TwilioResponse><SMSMessage><Sid>AP38503af035184c6a8b9cb9b7c70fb2b4</Sid><DateCreated>Wed, 18 Aug 2010 20:01:40 +0000</DateCreated><DateUpdated>Wed, 18 Aug 2010 20:01:40 +0000</DateUpdated><DateSent/><AccountSid>AC696f8df0c9ca45cfb59b073ad5e3ee02</AccountSid>\n""<To>+919904523387</To>\n"
        "<From>+%@</From>\n"
        "<Body>%@</Body>\n"
        "<Status>queued</Status>\n"
        "<Direction>outbound-api</Direction>\n"
        "<ApiVersion>2010-04-01</ApiVersion>\n"
        "<Price/>\n"
        "<Uri>/2010-04-01/Accounts/AP38503af035184c6a8b9cb9b7c70fb2b4/SMS/Messages/AC696f8df0c9ca45cfb59b073ad5e3ee02</Uri>\n"
        "</SMSMessage>\n"
        "</TwilioResponse>",fromNumber,toNumber,msg];
   
/*    NSData *data = [[NSString stringWithString:strXmlNode] dataUsingEncoding:NSUTF8StringEncoding];
   
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   
    NSString *documentsDirectory = [paths objectAtIndex:0];
   
    NSString *dataFilePath = [[documentsDirectory stringByAppendingPathComponent:@"Message.xml"] retain];
   
    [data writeToFile: dataFilePath atomically:YES]; */

To generate the random charter unto limit + iphone

 NSString *chars = @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    NSMutableString *randomString = [NSMutableString stringWithCapacity: string_length];
    for (int i=0; i<string_length; i++)
    {
        [randomString appendFormat:@"%C", [chars characterAtIndex: arc4random()%[chars length]]];
    }

Soap parsing Demos + iphone

Soap parsing Demos
http://www.devx.com/wireless/Article/43209
http://iphonebyradix.blogspot.com/2011/04/working-with-webservices.html
http://www.icodeblog.com/2008/11/03/iphone-programming-tutorial-intro-to-soap-web-services/
MPMediaItemArtwork
https://github.com/erica/MPMediaItem-Properties

MPMediaItemArtwork + custome movie player + iphone

MPMediaItemArtwork
https://github.com/erica/MPMediaItem-Properties

MPMediaItemArtwork + custome movie player + iphone

MPMediaItemArtwork
https://github.com/erica/MPMediaItem-Properties

multiselection of row in TableView + iphone

- (void)viewDidLoad {
    [super viewDidLoad];
    self.arForTable=[NSArray arrayWithObjects:@"Object-One",@"Object-Two",@"Object-Three",@"Object-Four",@"Object-Five", nil];
    self.arForIPs=[NSMutableArray array];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.arForTable count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    if([self.arForIPs containsObject:indexPath]){
        [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
    } else {
        [cell setAccessoryType:UITableViewCellAccessoryNone];
    }
    cell.textLabel.text=[self.arForTable objectAtIndex:indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if([self.arForIPs containsObject:indexPath]){
        [self.arForIPs removeObject:indexPath];
    } else {
        [self.arForIPs addObject:indexPath];
    }
    [tableView reloadData];
}

paypal library + iphone

paypal library
https://www.x.com/developers/paypal/documentation-tools/sdk

view like the easy out and view like small to big + iphone

http://stackoverflow.com/questions/8175367/iphone-uiview-animation-resize-in-like-disappear-in-water-and-comes-back-floatin
CGRect originalFrame = scheduleView.frame;
   
    [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
        CGRect frame = scheduleView.frame;
        frame.origin = scheduleView.center;
        frame.size = CGSizeMake( 0, 0 );
        scheduleView.frame = frame;
    } completion:^(BOOL finished) {
        // Do something with the view
       
        [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
           scheduleView.frame = originalFrame;
        } completion:^(BOOL finished) {
            return;
        }];
       
        return;
    }];

sectioned TableView + iphone

http://www.mobisoftinfotech.com/blog/iphone/iphone-uitableview-tutorial-grouped-table/
/*<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
 <key>Photo</key>
 <string>mobile.png</string>
 <key>Mobile Phones</key>
 <array>
 <string>GSM Phones</string>
 <string>Dual Sim Phones</string>
 <string>CDMA Phones</string>
 </array>
 <key>Smart Phones</key>
 <array>
 <string>IOS Phones</string>
 <string>Android OS Phones</string>
 <string>Blackberry Phones</string>
 <string>Symbian OS Phones</string>
 <string>Tablet Phones</string>
 <string>Windows OS Phones</string>
 <string>Bada OS Phones</string>
 </array>

 <key>Mobile Accessories</key>
 <array>
 <string>Screen Protectors</string>
 <string>Memory Card</string>
 <string>HeadPhones</string>
 <string>CaseMate</string>       
 <string>Bluetooth Devices</string>       
 </array>

 <key>Landline Phones</key>
 <array>
 <string>Landline Phones</string>
 </array>

 </dict>
 </plist>
 */

-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden=NO;
        self.title=@"Sub Category";
    appDel=(AppDelegate *)[[UIApplication sharedApplication]delegate];
    NSLog(@"indexValue %@",indexValue);
    NSString *getPlist=[[NSBundle mainBundle] pathForResource:indexValue ofType:@"plist"];
    NSLog(@"%@",getPlist);
    plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:getPlist];
    NSLog(@"%@",plistDict);
   
   
    NSString *getPhoto=[plistDict valueForKey:@"Photo"];
    UIImageView *bgImgView=[[UIImageView alloc] initWithFrame:CGRectMake(subCatTableView.frame.origin.x, subCatTableView.frame.origin.y, subCatTableView.frame.size.width, subCatTableView.frame.size.height)];
    bgImgView.image=[UIImage imageNamed:getPhoto];
    bgImgView.alpha=0.5;
    subCatTableView.backgroundView=bgImgView;
    [plistDict removeObjectForKey:@"Photo"];
   
   
   
    sectionArray=[[NSMutableArray alloc] init];

    sectionArray =[[[plistDict allKeys]sortedArrayUsingSelector:@selector(compare:)] mutableCopy];
   
    NSLog(@"%@",sectionArray);
    subCatArray=[[NSMutableArray alloc] init];
   

   
}
#pragma mark Table Methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return [sectionArray count];
}

- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
    return [sectionArray objectAtIndex:section];
}

- (NSInteger)tableView:(UITableView *)table
 numberOfRowsInSection:(NSInteger)section {
    NSArray *listData =[plistDict objectForKey:
                        [sectionArray objectAtIndex:section]];
    return [listData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
   
    NSArray *listData =[plistDict objectForKey:
                        [sectionArray objectAtIndex:[indexPath section]]];
   
    UITableViewCell * cell = [tableView
                              dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
   
    if(cell == nil) {
       
        cell = [[[UITableViewCell alloc]
                 initWithStyle:UITableViewCellStyleDefault
                 reuseIdentifier:SimpleTableIdentifier] autorelease];
         cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        /*cell = [[[UITableViewCell alloc]
         initWithStyle:UITableViewCellStyleSubtitle
         reuseIdentifier:SimpleTableIdentifier] autorelease];
         */
    }
    cell.selectionStyle=UITableViewCellSelectionStyleGray;
    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listData objectAtIndex:row];
   
    return cell;
}

- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSArray *listData =[plistDict objectForKey:
                        [sectionArray objectAtIndex:[indexPath section]]];
    NSUInteger row = [indexPath row];
    NSString *rowValue = [listData objectAtIndex:row];
   
    NSString *message = [[NSString alloc] initWithFormat:rowValue];
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"You selected"
                          message:message delegate:nil
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:nil];
    [alert show];
    [alert release];
    [message release];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
   
}

setting custom image to slider + iphone

UIImage *minImage = [UIImage imageNamed:@"grey_track.png"];
    UIImage *maxImage = [UIImage imageNamed:@"white_track.png"];
    UIImage *tumbImage= [UIImage imageNamed:@"metal_screw.png"];
   
    minImage=[minImage stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
    maxImage=[maxImage stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
   
    // Setup the FX slider
    [maxPriceSlider setMinimumTrackImage:minImage forState:UIControlStateNormal];
    [maxPriceSlider setMaximumTrackImage:maxImage forState:UIControlStateNormal];
    [maxPriceSlider setThumbImage:tumbImage forState:UIControlStateNormal];

pop to specific view in iPhone

pop to specific view in iPhone
[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: 1] animated: YES];

Slide to Unlock Demo of slider + iphone

altosdesign.com/iphonesdk/SlideToCancel.zip
    http://www.altosdesign.com/iphonesdk/SlideToCancel.zip

hexa code to UIColor + iphone

- (UIColor *) colorWithHexString: (NSString *) hex 

    NSString *cString = [[hex stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; 
   
    // String should be 6 or 8 characters 
    if ([cString length] < 6) return [UIColor grayColor]; 
   
    // strip 0X if it appears 
    if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2]; 
   
    if ([cString length] != 6) return  [UIColor grayColor]; 
   
    // Separate into r, g, b substrings 
    NSRange range; 
    range.location = 0; 
    range.length = 2; 
    NSString *rString = [cString substringWithRange:range]; 
   
    range.location = 2; 
    NSString *gString = [cString substringWithRange:range]; 
   
    range.location = 4; 
    NSString *bString = [cString substringWithRange:range]; 
   
    // Scan values 
    unsigned int r, g, b; 
    [[NSScanner scannerWithString:rString] scanHexInt:&r]; 
    [[NSScanner scannerWithString:gString] scanHexInt:&g]; 
    [[NSScanner scannerWithString:bString] scanHexInt:&b]; 
   
    return [UIColor colorWithRed:((float) r / 255.0f) 
                           green:((float) g / 255.0f) 
                            blue:((float) b / 255.0f) 
                           alpha:1.0f]; 
}
how to use it
[self.view setBackgroundColor: [self colorWithHexString:@"Ff0000"]];

sending one mail to bulkPeople + iphone

- (IBAction)emailBtnPress {
    if ([appDel connectedToInternet]==YES) {
        if ([MFMailComposeViewController canSendMail]  ){
            ABAddressBookRef addressBook = ABAddressBookCreate();
           
            CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
           
           
            CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
           
            NSMutableArray *emailIdArray= [[NSMutableArray alloc] init];
            for (int i = 0; i < nPeople; i++) {
               
                ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
                 
                ABMultiValueRef multiValue = ABRecordCopyValue(ref, kABPersonEmailProperty);
                NSLog(@"%@",multiValue);
               
                int count = ABMultiValueGetCount(multiValue);
                NSLog(@"%d",count);
                int j;
                for(j = 0; j < count; j++) {
                    NSString *label = (NSString *)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(multiValue, j));
                    NSString *value = (NSString *)ABMultiValueCopyValueAtIndex(multiValue, j);
                   
                    NSLog(@"Email for %@: %@", label, value);
                    [emailIdArray addObject:value];
                }               
             }
            NSLog(@"%@",emailIdArray);
            MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
            mailController.mailComposeDelegate = self;
            [mailController setCcRecipients:emailIdArray];
            [mailController setSubject:@"Sending bulk Email"];
            [self presentModalViewController:mailController animated:YES];
            [mailController release];
        }
        else{
            [appDel showAlert:@"!Opps" message:@"Your Device should not configured the mail account."];
        }
    }
    else{
        [appDel showAlert:@"!Opps" message:@"Check your network connection."];
    }
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{  
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Result: canceled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Result: saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Result: sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Result: failed");
            break;
        default:
            NSLog(@"Result: not sent");
            break;
    }
    [self becomeFirstResponder];
   
    [controller dismissModalViewControllerAnimated:YES];
}

converting the contact in the Vcard represantation and Sending Mail + iphone

- (NSString *)vCardRepresentation
{
  NSMutableArray *mutableArray = [[NSMutableArray alloc] init];

  [mutableArray addObject:@"BEGIN:VCARD"];
  [mutableArray addObject:@"VERSION:3.0"];

  [mutableArray addObject:[NSString stringWithFormat:@"FN:%@", self.name]];

  [mutableArray addObject:[NSString stringWithFormat:@"ADR:;;%@",
                           [self addressWithSeparator:@";"]]];

  if (self.phone != nil)
    [mutableArray addObject:[NSString stringWithFormat:@"TEL:%@", self.phone]];

  [mutableArray addObject:[NSString stringWithFormat:@"GEO:%g;%g",
                           self.latitudeValue, self.longitudeValue]];

  [mutableArray addObject:[NSString stringWithFormat:@"URL:http://%@",
                           self.website]];

  [mutableArray addObject:@"END:VCARD"];

  NSString *string = [mutableArray componentsJoinedByString:@"\n"];

  [mutableArray release];

  return string;
}
For sending mail for vcf file
 CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
  
 if ([MFMailComposeViewController canSendMail]){
       
    NSData *vCards = (NSData *) ABPersonCreateVCardRepresentationWithPeople(allPeople);
   
    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; 
    mc.mailComposeDelegate = self; 
   
    [mc setSubject:@"Contact"];
   
    [mc setMessageBody:@"<p>My message...<p>" isHTML:YES];
       
        ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, 1);
       
       
      //  CFStringRef firstName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
       
     //   NSString *contactFirst = [NSString stringWithFormat: @"%@", (NSString *)firstName];
       
     //  NSString *label = ([allPeople count] == 1)? (NSString *)ABRecordCopyCompositeName([allPeople objectAtIndex:0]): @"Contacts";
   
    [mc addAttachmentData:vCards mimeType:@"text/x-vcard" fileName:@"All.vcf"];//
   
    [self presentModalViewController:mc animated:YES]; 
    [mc release]; 
  
    }

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{  
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Result: canceled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Result: saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Result: sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Result: failed");
            break;
        default:
            NSLog(@"Result: not sent");
            break;
    }
    [self becomeFirstResponder];
   
    [controller dismissModalViewControllerAnimated:YES];
}

Weather Demo + iphone

http://learningiphoneprogramming.com/pages/samplecode.html

Mail from gmail or yahoo account + iphone

http://sourceforge.net/projects/nimitparekh/files/mail%20transfer%20using%20GMAIL/mailTransfer.zip/download

Creating the contact group in iphone

ABAddressBookRef  addressBook = ABAddressBookCreate();   
    CFErrorRef err = nil;
    ABRecordRef group = ABGroupCreate();
    ABRecordSetValue(group, kABGroupNameProperty, @"MCA", &err);
   
   ABAddressBookRemoveRecord(addressBook,group, &err);
    ABAddressBookSave(addressBook, &err);
 //Removing group
-(BOOL)removeGroup{
    BOOL res;
    CFErrorRef error;
    ABAddressBookRef ab = ABAddressBookCreate();
   
    NSArray *groups = (NSArray *) ABAddressBookCopyArrayOfAllGroups(ab);
   
    for (id _group in groups)
    {
        NSString *currentGroupName = [[NSString alloc] init];
        currentGroupName = (NSString*) ABRecordCopyValue(_group, kABGroupNameProperty);
       
        if ([@"MCA" isEqualToString:currentGroupName])
        {
            [currentGroupName release];
            res = ABAddressBookRemoveRecord(ab, _group, &error);
            ABAddressBookSave(ab, nil);
            return res;
        }
        [currentGroupName release];
    }
   
    return NO;
}

parsing of Images tag from the string in + iphone

- (NSString *)getFirstImage:(NSString *)htmlString{
  NSString *urlImage=nil;
    NSScanner *theScanner = [NSScanner scannerWithString:htmlString];
    // find start of IMG tag
    [theScanner scanUpToString:@"<img" intoString:nil];
    do {
        [theScanner scanUpToString:@"src" intoString:nil];
        NSCharacterSet *charset = [NSCharacterSet characterSetWithCharactersInString:@"\"'"];
        [theScanner scanUpToCharactersFromSet:charset intoString:nil];
        [theScanner scanCharactersFromSet:charset intoString:nil];
        [theScanner scanUpToCharactersFromSet:charset intoString:&urlImage];

        if([urlImage rangeOfString:@"imagebutton.gif"].location == NSNotFound) return urlImage;


    }while (![theScanner isAtEnd]  );


    if([theScanner isAtEnd]) return nil;
     return urlImage;
}

custom progressView + iphone

   http://www.obsessivecode.com/projects/ocprogress/

Wenggling and vibrations of any object + iphone

- (void)startWobble {
    resultImage.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-5));
   
    [UIView animateWithDuration:0.25
                          delay:0.0
                        options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)
                     animations:^ {
                         resultImage.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(5));
                     }
                     completion:NULL
     ];

}
[self startWobble];
- (void)stopWobble {
 [UIView animateWithDuration:0.25
      delay:0.0
      options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear)
      animations:^ {
       itemView.transform = CGAffineTransformIdentity;
      }
      completion:NULL
  ];
}
//For the shake/vibration of unbutton
https://github.com/jonasschnelli/UIView-I7ShakeAnimation

 

pop view like push view in iphone

[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: 1] animated: YES];

sending and receiving data to the server + iphone

http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-receive-data-from-the-server-in-iphone/

CALayer rotating of ball within center in iphone

http://www.2shared.com/file/BaJ18c2U/CALayerAnimTEst.htm

URL Escaping + iphone

$  %24
&  %26
+  %2B
,  %2C
/  %2F
:  %3A
;  %3B
=  %3D
?  %3F
@  %40
- (NSString*)stringWithPercentEscape {          
    return [(NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[[self mutableCopy] autorelease], NULL, CFSTR("=,!$&'()*+;@?\n\"<>#\t :/"),kCFStringEncodingUTF8) autorelease];
}

Saving & Retriving the images to NSUserDefault + iphone

1 ) [[NSUserDefaults standardUserDefaults] setObject:UIImagePNGRepresentation(image) forKey:@"foo"];
or
1 ) NSData *imageData;
// create NSData-object from image
imageData = UIImagePNGRepresentation([dic objectForKey:[NSString stringWithFormat:@"%d",i]]);
// save NSData-object to UserDefaults
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:[NSString stringWithFormat:@"%d",i]];

//For Getting images from NSUserDefault

NSData *imageData;
// Load NSData-object from NSUserDefault
imageData = [[NSUserDefaults standardUserDefaults] valueForKey:[NSString stringWithFormat:@"%d",i]];
// get Image from NSData
[image setObject:[UIImage imageWithData:imageData] forKey:[NSString stringWithFormat:@"%d",i]];

Runtime Content side of UIScrollView + iphone

CGRect contentSize = CGRectZero;
    for (UIView *subview in scrollView.subviews) {
        contentSize = CGRectUnion(contentSize, subview.frame);
    }
    scrollView.contentSize = contentSize.size;

For the rotating any object round round from center in iphone

CALayer *orbit1 = [CALayer layer];
    orbit1.bounds = CGRectMake(0, 0, 200, 200);
    orbit1.position = self.view.center;
    orbit1.cornerRadius = 100;
    orbit1.borderColor = [UIColor clearColor].CGColor;
    orbit1.borderWidth = 1.5;
   
    CALayer *planet1 = [CALayer layer];
    planet1.bounds = CGRectMake(0, 0, 20, 20);
    planet1.position = CGPointMake(100, 0);
    planet1.cornerRadius = 10;
    planet1.backgroundColor = [UIColor redColor].CGColor;
    [orbit1 addSublayer:planet1];
   
    CABasicAnimation *anim1 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    anim1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    anim1.fromValue = [NSNumber numberWithFloat:0];
    anim1.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
    anim1.repeatCount = HUGE_VALF;
    anim1.duration = 8.0;
    [orbit1 addAnimation:anim1 forKey:@"transform"];
   
    [self.view.layer addSublayer:orbit1];


Custom TabBar Demos in iphone

https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar
https://github.com/boctor/idev-recipes

For the encryption and decryption Iphone

https://gist.github.com/838614

For the different snippet of iphone

http://super-mak.blogspot.in/2011/03/create-pdf-file-in-iphone-sdk.html
http://projectswithlove.com/projects/
http://osx.hyperjeff.net/Reference/CocoaArticles?cat=52
http://www.vellios.com/downloads/
http://iphonecode.weebly.com/second-page.html
 http://borkware.com/quickies/everything-by-date
http://jidh.weebly.com/iphone-development.html
http://pragprog.com/titles/cdirec/source_code
http://www.codingventures.com/2008/12/useful-open-source-libraries-for-iphone-development/
http://iphoneapp-dev.blogspot.com/2011/05/this-example-shows-how-to-upload-images.html http://www.scoop.it/t/iphone-and-ipad-development/p/5853246/show-a-custom-popover-view-within-your-ipad-app-seaside
http://iphonecode.weebly.com/iphone-learning-codes.html
http://code.google.com/p/iphone-sdk-programming-book-code-samples/
http://www.iphoneexamples.com/
http://pragprog.com/titles/cdirec/source_code
http://www.theiphonedev.com/SourceCode/tabid/143/Default.aspx
http://iphone.zcentric.com/
http://www.bogotobogo.com/XcodeSDK-Chapter12.html
http://www.scoop.it/t/iphone-and-ipad-development/p/161462636/back-to-basis-gridview-using-interface-builder-in-iphone
http://iphone.zcentric.com/

cocos2d tutorials + iphone

http://dev.lethain.com/notes-on-cocos2d-iphone-development/
http://www.iphonegametutorials.com/2010/09/03/getting-started-with-cocos2d/

For the custom Media Player in iphone


For the custom Media Player in iphone

http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-music-library-access/

For the custom Media Player in iphone


urldemo 8

//For the custom Media Player in iphone
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-music-library-access/

//For the different snippet
http://super-mak.blogspot.in/2011/03/create-pdf-file-in-iphone-sdk.html

// For the cocos2d tutorials
http://dev.lethain.com/notes-on-cocos2d-iphone-development/
http://www.iphonegametutorials.com/2010/09/03/getting-started-with-cocos2d/

//For the encryption and decryption
https://gist.github.com/838614

//For the all type of Custom Demo like uitabbar
https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar

//For the rotating the any object round round
 CALayer *orbit1 = [CALayer layer];
    orbit1.bounds = CGRectMake(0, 0, 200, 200);
    orbit1.position = self.view.center;
    orbit1.cornerRadius = 100;
    orbit1.borderColor = [UIColor clearColor].CGColor;
    orbit1.borderWidth = 1.5;
   
    CALayer *planet1 = [CALayer layer];
    planet1.bounds = CGRectMake(0, 0, 20, 20);
    planet1.position = CGPointMake(100, 0);
    planet1.cornerRadius = 10;
    planet1.backgroundColor = [UIColor redColor].CGColor;
    [orbit1 addSublayer:planet1];
   
    CABasicAnimation *anim1 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    anim1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    anim1.fromValue = [NSNumber numberWithFloat:0];
    anim1.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
    anim1.repeatCount = HUGE_VALF;
    anim1.duration = 8.0;
    [orbit1 addAnimation:anim1 forKey:@"transform"];
   
    [self.view.layer addSublayer:orbit1];


//For the Content side of UIScrollView

CGRect contentSize = CGRectZero;
    for (UIView *subview in scrollView.subviews) {
        contentSize = CGRectUnion(contentSize, subview.frame);
    }
    scrollView.contentSize = contentSize.size;

Friday, 17 February 2012

urldemo 7

//For Setting images to NSUserDefault

1 ) [[NSUserDefaults standardUserDefaults] setObject:UIImagePNGRepresentation(image) forKey:@"foo"];
or
1 ) NSData *imageData;
// create NSData-object from image
imageData = UIImagePNGRepresentation([dic objectForKey:[NSString stringWithFormat:@"%d",i]]);
// save NSData-object to UserDefaults
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:[NSString stringWithFormat:@"%d",i]];

//For Getting images from NSUserDefault

NSData *imageData;
// Load NSData-object from NSUserDefault
imageData = [[NSUserDefaults standardUserDefaults] valueForKey:[NSString stringWithFormat:@"%d",i]];
// get Image from NSData
[image setObject:[UIImage imageWithData:imageData] forKey:[NSString stringWithFormat:@"%d",i]];

//url Escaping.
$  %24
&  %26
+  %2B
,  %2C
/  %2F
:  %3A
;  %3B
=  %3D
?  %3F
@  %40
- (NSString*)stringWithPercentEscape {          
    return [(NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[[self mutableCopy] autorelease], NULL, CFSTR("=,!$&'()*+;@?\n\"<>#\t :/"),kCFStringEncodingUTF8) autorelease];
}


//For the CALayer rotating of ball within center
http://www.2shared.com/file/BaJ18c2U/CALayerAnimTEst.htm

//For the sending and receiving data to the server
http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-receive-data-from-the-server-in-iphone/

//For pop view like push
     [self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: 1] animated: YES];
  

//For the Wenggling of any things
- (void)startWobble {
    resultImage.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-5));
   
    [UIView animateWithDuration:0.25
                          delay:0.0
                        options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)
                     animations:^ {
                         resultImage.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(5));
                     }
                     completion:NULL
     ];

}
[self startWobble];
- (void)stopWobble {
 [UIView animateWithDuration:0.25
      delay:0.0
      options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear)
      animations:^ {
       itemView.transform = CGAffineTransformIdentity;
      }
      completion:NULL
  ];
}
//For the shake/vibration of unbutton
https://github.com/jonasschnelli/UIView-I7ShakeAnimation

 

Saturday, 4 February 2012

urldemo 6

//    SKU=Stock Keeping Unit

//For the custom progressView
    http://www.obsessivecode.com/projects/ocprogress/

//For the parsing of <img src> tag from the string
- (NSString *)getFirstImage:(NSString *)htmlString{



    NSString *urlImage=nil;
    NSScanner *theScanner = [NSScanner scannerWithString:htmlString];
    // find start of IMG tag
    [theScanner scanUpToString:@"<img" intoString:nil];
    do {
        [theScanner scanUpToString:@"src" intoString:nil];
        NSCharacterSet *charset = [NSCharacterSet characterSetWithCharactersInString:@"\"'"];
        [theScanner scanUpToCharactersFromSet:charset intoString:nil];
        [theScanner scanCharactersFromSet:charset intoString:nil];
        [theScanner scanUpToCharactersFromSet:charset intoString:&urlImage];

        if([urlImage rangeOfString:@"imagebutton.gif"].location == NSNotFound) return urlImage;


    }while (![theScanner isAtEnd]  );


    if([theScanner isAtEnd]) return nil;
     return urlImage;
}


//For Rss links for iPhone themes

    http://iphonethemes.net/rss1/Abstract
    1 to 26

 //creating group
  
      ABAddressBookRef  addressBook = ABAddressBookCreate();   
    CFErrorRef err = nil;
    ABRecordRef group = ABGroupCreate();
    ABRecordSetValue(group, kABGroupNameProperty, @"MCA", &err);
   
   ABAddressBookRemoveRecord(addressBook,group, &err);
    ABAddressBookSave(addressBook, &err);
 //Removing group
-(BOOL)removeGroup{
    BOOL res;
    CFErrorRef error;
    ABAddressBookRef ab = ABAddressBookCreate();
   
    NSArray *groups = (NSArray *) ABAddressBookCopyArrayOfAllGroups(ab);
   
    for (id _group in groups)
    {
        NSString *currentGroupName = [[NSString alloc] init];
        currentGroupName = (NSString*) ABRecordCopyValue(_group, kABGroupNameProperty);
       
        if ([@"MCA" isEqualToString:currentGroupName])
        {
            [currentGroupName release];
            res = ABAddressBookRemoveRecord(ab, _group, &error);
            ABAddressBookSave(ab, nil);
            return res;
        }
        [currentGroupName release];
    }
   
    return NO;
}


//For sending mail from gmail or yahoo account
http://sourceforge.net/projects/nimitparekh/files/mail%20transfer%20using%20GMAIL/mailTransfer.zip/download

//For the weather demo
http://learningiphoneprogramming.com/pages/samplecode.html

///For the converting the contact in the Vcard form

- (NSString *)vCardRepresentation
{
  NSMutableArray *mutableArray = [[NSMutableArray alloc] init];

  [mutableArray addObject:@"BEGIN:VCARD"];
  [mutableArray addObject:@"VERSION:3.0"];

  [mutableArray addObject:[NSString stringWithFormat:@"FN:%@", self.name]];

  [mutableArray addObject:[NSString stringWithFormat:@"ADR:;;%@",
                           [self addressWithSeparator:@";"]]];

  if (self.phone != nil)
    [mutableArray addObject:[NSString stringWithFormat:@"TEL:%@", self.phone]];

  [mutableArray addObject:[NSString stringWithFormat:@"GEO:%g;%g",
                           self.latitudeValue, self.longitudeValue]];

  [mutableArray addObject:[NSString stringWithFormat:@"URL:http://%@",
                           self.website]];

  [mutableArray addObject:@"END:VCARD"];

  NSString *string = [mutableArray componentsJoinedByString:@"\n"];

  [mutableArray release];

  return string;
}
For sending mail for vcf file
 CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
  
 if ([MFMailComposeViewController canSendMail]){
       
    NSData *vCards = (NSData *) ABPersonCreateVCardRepresentationWithPeople(allPeople);
   
    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; 
    mc.mailComposeDelegate = self; 
   
    [mc setSubject:@"Contact"];
   
    [mc setMessageBody:@"<p>My message...<p>" isHTML:YES];
       
        ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, 1);
       
       
      //  CFStringRef firstName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
       
     //   NSString *contactFirst = [NSString stringWithFormat: @"%@", (NSString *)firstName];
       
     //  NSString *label = ([allPeople count] == 1)? (NSString *)ABRecordCopyCompositeName([allPeople objectAtIndex:0]): @"Contacts";
   
    [mc addAttachmentData:vCards mimeType:@"text/x-vcard" fileName:@"All.vcf"];//
   
    [self presentModalViewController:mc animated:YES]; 
    [mc release]; 
  
    }

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{  
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Result: canceled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Result: saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Result: sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Result: failed");
            break;
        default:
            NSLog(@"Result: not sent");
            break;
    }
    [self becomeFirstResponder];
   
    [controller dismissModalViewControllerAnimated:YES];
}
   
//For the sending one mail to bulkPeople
- (IBAction)emailBtnPress {
    if ([appDel connectedToInternet]==YES) {
        if ([MFMailComposeViewController canSendMail]  ){
            ABAddressBookRef addressBook = ABAddressBookCreate();
           
            CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
           
           
            CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
           
            NSMutableArray *emailIdArray= [[NSMutableArray alloc] init];
            for (int i = 0; i < nPeople; i++) {
               
                ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
                 
                ABMultiValueRef multiValue = ABRecordCopyValue(ref, kABPersonEmailProperty);
                NSLog(@"%@",multiValue);
               
                int count = ABMultiValueGetCount(multiValue);
                NSLog(@"%d",count);
                int j;
                for(j = 0; j < count; j++) {
                    NSString *label = (NSString *)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(multiValue, j));
                    NSString *value = (NSString *)ABMultiValueCopyValueAtIndex(multiValue, j);
                   
                    NSLog(@"Email for %@: %@", label, value);
                    [emailIdArray addObject:value];
                }               
             }
            NSLog(@"%@",emailIdArray);
            MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
            mailController.mailComposeDelegate = self;
            [mailController setCcRecipients:emailIdArray];
            [mailController setSubject:@"Sending bulk Email"];
            [self presentModalViewController:mailController animated:YES];
            [mailController release];
        }
        else{
            [appDel showAlert:@"!Opps" message:@"Your Device should not configured the mail account."];
        }
    }
    else{
        [appDel showAlert:@"!Opps" message:@"Check your network connection."];
    }
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{  
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Result: canceled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Result: saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Result: sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Result: failed");
            break;
        default:
            NSLog(@"Result: not sent");
            break;
    }
    [self becomeFirstResponder];
   
    [controller dismissModalViewControllerAnimated:YES];
}