iphone xcode annotation pin drop with slider value change also remove

Posted by chirag on Stack Overflow See other posts from Stack Overflow or by chirag
Published on 2010-04-02T21:47:50Z Indexed on 2010/04/02 21:53 UTC
Read the original article Hit count: 1102

Filed under:
|

i have to add annotation pin on location with UIslider Value change .... this is code where i add annotation

  • (MKAnnotationView *) mapView:(MKMapView *)mapView1 viewForAnnotation:(id ) annotation{

    MKAnnotationView* annotationView = nil; NSString* identifier = @"Pin"; MyAnnotationView* annView = (MyAnnotationView*)[mapView1 dequeueReusableAnnotationViewWithIdentifier:identifier]; // annotationView.leftCalloutAccessoryView = myImage; //myImage = [UIButton buttonWithType:UIButtonTypeCustom]; // [myImage setImage:[UIImage imageNamed:@"mark.png"]forState:UIControlStateNormal];

    //Property_Photo UIButton *mybtn = [UIButton buttonWithType:UIButtonTypeCustom]; if([annotation isKindOfClass:[AddressAnnotation class]]){ AddressAnnotation x=(AddressAnnotation)annotation;

    mybtn.frame = CGRectMake(0, 0, 35, 35);
    mybtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    mybtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;   
    [mybtn setImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal];
    [mybtn setTitle:[NSString stringWithFormat:@"%@",[x getID]] forState:UIControlStateDisabled];
    
    
    [mybtn addTarget:self action:@selector(btnShowProperty:) forControlEvents:UIControlEventTouchUpInside];
    ((IMOVEISAppDelegate*)[[UIApplication sharedApplication]delegate]).strPropertyPrice = [[myTblArray objectAtIndex:imgIndex]valueForKey:@"Property_Price"];   
    NSLog(@"property price: %@",((IMOVEISAppDelegate*)[[UIApplication sharedApplication]delegate]).strPropertyPrice);
    
    
    if(nil == annView) {
        ///if(annView!=nil && [annView retainCount]>0){ [annView release]; annView=nil; }
    
    
    
    annView = [[[MyAnnotationView alloc] initWithAnnotation:x reuseIdentifier:identifier] autorelease];
    
    
    if(Objslider.value==10){
    
    
        [myMapView removeAnnotations:myMapView.annotations];
    
    
    }
    
    
    }
    
    NSURL *imgURL = [NSURL URLWithString:[[myTblArray objectAtIndex:imgIndex]valueForKey:@"Property_Photo"]]; UIImage *imgPhoto = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgURL]]; UIImageView *pinImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0,35, 35)]; imgIndex++; [pinImgView setImage:imgPhoto]; annView.rightCalloutAccessoryView = mybtn; annView.leftCalloutAccessoryView = pinImgView; [annView setBackgroundColor:[UIColor clearColor]];

    } [annView setEnabled:YES];
    annView.canShowCallout = YES; annView.calloutOffset = CGPointMake(-5, 5);

    annotationView = annView; return annotationView; }

© Stack Overflow or respective owner

Related posts about iphone

Related posts about xcode