Hi,
Most of the time there are requirement when we have to perform some action on single tap and other independent action on double tap.
The problem that occurs is when we double tap,single tap method is always called.
There are some situations in which we do not want the single tap action get performed when doing double tap.
In touches ended method write:-
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet *allTouches=[event allTouches];
switch ([allTouches count]) {
case 1:
{
UITouch *touch=[[allTouches allObjects]objectAtIndex:0];
switch ([touch tapCount])
{
case 1:
NSLog(@"single touch");
[self performSelector:@selector(singletap) withObject:nil afterDelay:0.3];
break;
case 2:
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singletap) object:nil];
NSLog(@"double touch");
break;
}
break;
}
break;
}
Happy coding:)
Wednesday, 20 July 2011
Phone Calling Integration
Hi ,
This blog describe how to make a call in an iphone application.
This blog is useful in the situations where there is a field shown phone number and when you click on it ,call will be initiated on that number.
-(void_initiateCall
{
NSString *phoneNo=@" phone number";
NSString *telephoneString=[phoneNo stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSMutableString *str1=[[NSMutableString alloc] initWithString:telephoneString];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@"(" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@")" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@"-" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@" " withString:@""]];
telephoneString = [@"tel://" stringByAppendingString:str1];
[str1 release];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneString]];
}
Happy Coding:)
This blog describe how to make a call in an iphone application.
This blog is useful in the situations where there is a field shown phone number and when you click on it ,call will be initiated on that number.
-(void_initiateCall
{
NSString *phoneNo=@" phone number";
NSString *telephoneString=[phoneNo stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSMutableString *str1=[[NSMutableString alloc] initWithString:telephoneString];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@"(" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@")" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@"-" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@" " withString:@""]];
telephoneString = [@"tel://" stringByAppendingString:str1];
[str1 release];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneString]];
}
Happy Coding:)
Customizing user current location Annotation
Hi ,
We all know when Our Current Location is shown as blue dot on mapView.
There are some situations when we have to show some other annotation rather than blue dot.
Here's the code by which you can customize your current location
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if (annotation == mapView.userLocation)
{
//return nil;
MKPinAnnotationView *customPinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] autorelease];
if (annotation == mapView.userLocation)
customPinView.image = [UIImage imageNamed:@"userLocImgae.png"];//write image name that you want to show
return customPinView;
}
Happy Coding:)
Core Graphics Drawing
Hi ,
Core Graphics is one of the most powerful framework of cocoa-touch.
Lots of animation,Drawings,Coloring etc features are provided in it.
Today in this blog I will explain how to start with core graphics, basically this blogs contributes how to draw different shapes and with different styles.
1.)Drawing a Line Segment:-
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextMoveToPoint(context, 50, 200);
CGContextAddLineToPoint(context,100,100);
CGContextMoveToPoint(context, 50, 200);
CGContextAddLineToPoint(context,200,400);
CGContextStrokePath(context);
2.)Drawing a Filled Circle
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(contextRef, 255, 0, 255, 0.9);
CGContextSetRGBStrokeColor(contextRef, 255, 0, 0, 0.9);
CGContextFillEllipseInRect(contextRef, CGRectMake(100, 100, 50, 50));
3.)Drawing a Hollow Circle
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(contextRef, 255, 0, 255, 0.9);
CGContextSetRGBStrokeColor(contextRef, 255, 0, 0, 0.9);
CGContextStrokeEllipseInRect(contextRef, CGRectMake(200, 100, 50, 50));
4.)Drawing a circle with boundary
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0, 255, 0, 1);
CGContextFillEllipseInRect(context, CGRectMake(100, 200, 25, 25));
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextStrokeEllipseInRect(context,CGRectMake(100, 200, 25, 25));
5.)Drawing a Hollow Rectangle
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(ctx, 255, 255, 0, 1);
CGContextStrokeRect(ctx, CGRectMake(195, 195, 60, 60));
6.)Drawing a Solid Rectangle
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(ctx, 255, 255, 0, 1);
CGContextFillRect(ctx, CGRectMake(260, 195, 60, 60));
7.)Drawing a Triangle
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(ctx, 255, 0, 255, 1);
CGPoint points[6] = { CGPointMake(200, 200), CGPointMake(250, 250),
CGPointMake(250, 250), CGPointMake(100, 250),
CGPointMake(100, 250), CGPointMake(200, 200) };
CGContextStrokeLineSegments(ctx, points, 6);
I hope this blog will help you in drawing these shapes with different styles.
Happy Coding:)
Core Graphics is one of the most powerful framework of cocoa-touch.
Lots of animation,Drawings,Coloring etc features are provided in it.
Today in this blog I will explain how to start with core graphics, basically this blogs contributes how to draw different shapes and with different styles.
1.)Drawing a Line Segment:-
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextMoveToPoint(context, 50, 200);
CGContextAddLineToPoint(context,100,100);
CGContextMoveToPoint(context, 50, 200);
CGContextAddLineToPoint(context,200,400);
CGContextStrokePath(context);
2.)Drawing a Filled Circle
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(contextRef, 255, 0, 255, 0.9);
CGContextSetRGBStrokeColor(contextRef, 255, 0, 0, 0.9);
CGContextFillEllipseInRect(contextRef, CGRectMake(100, 100, 50, 50));
3.)Drawing a Hollow Circle
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(contextRef, 255, 0, 255, 0.9);
CGContextSetRGBStrokeColor(contextRef, 255, 0, 0, 0.9);
CGContextStrokeEllipseInRect(contextRef, CGRectMake(200, 100, 50, 50));
4.)Drawing a circle with boundary
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0, 255, 0, 1);
CGContextFillEllipseInRect(context, CGRectMake(100, 200, 25, 25));
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextStrokeEllipseInRect(context,CGRectMake(100, 200, 25, 25));
5.)Drawing a Hollow Rectangle
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(ctx, 255, 255, 0, 1);
CGContextStrokeRect(ctx, CGRectMake(195, 195, 60, 60));
6.)Drawing a Solid Rectangle
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(ctx, 255, 255, 0, 1);
CGContextFillRect(ctx, CGRectMake(260, 195, 60, 60));
7.)Drawing a Triangle
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(ctx, 255, 0, 255, 1);
CGPoint points[6] = { CGPointMake(200, 200), CGPointMake(250, 250),
CGPointMake(250, 250), CGPointMake(100, 250),
CGPointMake(100, 250), CGPointMake(200, 200) };
CGContextStrokeLineSegments(ctx, points, 6);
I hope this blog will help you in drawing these shapes with different styles.
Happy Coding:)
Subscribe to:
Posts (Atom)