Friday, 24 February 2012

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];