Loading

Tuesday, July 20, 2010

What is Annotation ???

It is a pre-Declared Class.
You have to define it in your project.
The Annotation class must have three property
1-> coordinate
2-> title
3-> subtitle

:)
also declare and define method for initiate Annotation (it is user Define)

Example :-
Add New Class in Project Named MyAnnotaion
MyAnnotation.h

@interface MyAnnotation : NSObject {
CLLocationCoordinate2D _coordinate;
NSString* title;
NSString* subtitle;
}

@property (nonatomic, retain)NSString* title;
@property (nonatomic, retain)NSString* subtitle;

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate: (NSString*)annTitle : (NSString*)annSubTitle;
@end

MyAnnotation.m

@synthesize coordinate=_coordinate;
@synthesize title;
@synthesize subtitle;


- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate: (NSString*)annTitle : (NSString*)annSubTitle{
self = [super init];
if (self != nil) {
_coordinate = coordinate;
title = annTitle;
subtitle = annSubTitle;
}
return self;
}



Thursday, July 15, 2010

Smooth Line Eraser From View

UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:touch.view];
touchLocation = [touch locationInView:self.view];
CGPoint currentPoint = [touch locationInView:self.view];
CGContextRef Mycontext=UIGraphicsGetCurrentContext();

UIGraphicsBeginImageContext(Image_Cookie.frame.size);
[Image_Cookie.image drawInRect:CGRectMake(0, 0, Image_Cookie.frame.size.width, Image_Cookie.frame.size.height)];
CGContextSetLineCap(Mycontext,kCGImageAlphaPremultipliedLast); //kCGImageAlphaPremultipliedLast);
CGContextSetLineWidth(Mycontext, 10);
CGContextSetRGBStrokeColor(Mycontext, 1, 0, 0, 20);
CGContextBeginPath(Mycontext);
CGContextMoveToPoint(Mycontext, lastPoint.x, lastPoint.y);

int x, cx, deltax, xstep,y, cy, deltay, ystep,error, st, dupe;
int x0, y0, x1, y1;

x0 = currentPoint.x;
y0 = currentPoint.y;
x1 = lastPoint.x;
y1 = lastPoint.y;

// find largest delta for pixel steps
st = (abs(y1 - y0) > abs(x1 - x0));

// if deltay > deltax then swap x,y
if (st) {
(x0 ^= y0); (y0 ^= x0); (x0 ^= y0); // swap(x0, y0);
(x1 ^= y1); (y1 ^= x1); (x1 ^= y1); // swap(x1, y1);
}

deltax = abs(x1 - x0);
deltay = abs(y1 - y0);
error = (deltax / 2);
y = y0;

if (x0 > x1) { xstep = -1; }
else { xstep = 1; }

if (y0 > y1) { ystep = -1; }
else { ystep = 1; }

for ((x = x0); (x != (x1 + xstep)); (x += xstep))
{
(cx = x); (cy = y); // copy of x, copy of y

// if x,y swapped above, swap them back now
if (st) { (cx ^= cy); (cy ^= cx); (cx ^= cy); }

(dupe = 0); // initialize no dupe

if(!dupe) {
CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectMake(cx, cy,40, 40));
}

(error -= deltay); // converge toward end of line

if (error < 0) { // not done yet
(y += ystep);
(error += deltax);
}
}

CGContextStrokePath(Mycontext);
Image_Cookie.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

lastPoint = currentPoint;

Friday, July 9, 2010

Compass Niddel Set By User

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
theEndPoint = [touch locationInView:self.view];
if((theEndPoint.x>My_Compass.frame.origin.x && theEndPoint.y>My_Compass.frame.origin.y) && (theEndPoint.x {
float Centre_X = My_Compass.frame.origin.x + (My_Compass.frame.size.height/2);
float Centre_Y = My_Compass.frame.origin.y + (My_Compass.frame.size.width/2);

float dx=theEndPoint.x-Centre_X;
float dy=theEndPoint.y-Centre_Y;

double angle=atan2(dy,dx);
double br = RadiansTodegrees(angle);

CGAffineTransform rotate = CGAffineTransformMakeRotation(((br+90)/180)*3.14);
[Niddel setTransform:rotate];

}

}

Monday, July 5, 2010

Rename Project

Just Change the value of Bundle Display Name to My Project from ${PRODUCT_NAME}