Saturday, September 5, 2009

Interesting iPhone Games with Coding Helps!

iPhone slider Game !!


iPhone racing Game !!

Nice iPhone tutorials !!

Get Game and google Map Tutorials at:

Nice Games


Google map Tutorial

Feel iPhone accelerometer effect on simulator !!

Watch out the link...

Accelerometer Effect on Simulator !!

Thursday, September 3, 2009

Rotate an Image using Core Graphics in iPhone!!!

UIImage* rotatingImage = [UIImage imageNamed:@"someImage.png"];

CATransform3D rotationTransform
= CATransform3DMakeRotation(1.0f * M_PI, 0, 0, 1.0);
CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];

rotationAnimation
.toValue = [NSValue valueWithCATransform3D:rotationTransform];
rotationAnimation
.duration = 0.25f;
rotationAnimation
.cumulative = YES;
rotationAnimation
.repeatCount = 10;

[rotatingImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

A Category on iPhone NavigationBar to set image in background!!!

-(void)setBackgroundImage:(UIImage*)image withTag:(NSInteger)bgTag{
if(image == NULL){ //might be called with NULL argument
return;
}
UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:image];
aTabBarBackground
.frame = CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
aTabBarBackground
.tag = bgTag;
[self addSubview:aTabBarBackground];
[self sendSubviewToBack:aTabBarBackground];
[aTabBarBackground release];
}
/* input: The tag you chose to identify the view */
-(void)resetBackground:(NSInteger)bgTag {
[self sendSubviewToBack:[self viewWithTag:bgTag]];
}

After That call the method like:

[navigationControllerForChannels.navigationBar setBackgroundImage:[UIImage imageNamed:@"top_bar.png"] withTag:48151623];

After any Modification to the Bar call:

[self.navigationController.navigationBar resetBackground:48151623];


Wednesday, September 2, 2009

Make iPhone NavigationBar of Custom Color!!!

navigationBar.tintColor = [UIColor colorWithRed:.7 green:.5 blue:.2 alpha:1];

Very simple rules for memory management in iPhone

In iPhone Development You must do your own memory management through reference counting, using -retain, -release and -autorelease.

Retain Count rules

  1. Within a given block, the use of -copy, -alloc and -retain should equal the use of -release and -autorelease.
  2. Objects created using convenience constructors (e.g. NSString's stringWithString) are considered autoreleased.
  3. Implement a -dealloc method to release the instance variables you own.
Method Description
-retain increases the reference count of an object by 1
-release decreases the reference count of an object by 1
-autorelease decreases the reference count of an object by 1 at some stage in the future
-alloc allocates memory for an object, and returns it with retain count of 1
-copy makes a copy of an object, and returns it with retain count of 1

To set an image as background of iPhone UIView!!

Include an image of png extension in your project bundle and paste following line of code with your image name in viewDidLoad....


NSString *backgroundPath = [[ NSBundle mainBundle ] pathForResource : @"login" ofType : @"png" ];


UIImage *backgroundImage = [ UIImage imageWithContentsOfFile :backgroundPath];


UIColor *backgroundColor = [[ UIColor alloc ] initWithPatternImage :backgroundImage];


self .view.backgroundColor = backgroundColor;


[backgroundColor
release ];