1

I'm fairly new to xcode and iPhone development and I'm wondering if it's possible to basically take your standard map callout with one line of text with a button at the far right, and double that within one callout. So it's one double-high callout bubble with two lines of text on top of each other, each one with a button at the far right of it. Practically, I would like the first one to go to a details page and the second one to offer directions to the annotation. Is there a way to make a custom callout as described without getting too complicated?

Ryan
  • 570
  • 9
  • 25
  • Do you want to click on pin, it should show annotation view having one line and button at far right, and again clicking on far right button, annotation view should reload to display detail? – jigneshbrahmkhatri Jul 06 '11 at 19:01
  • I want it to show the callout with the two lines and buttons on the first touch of the annotation. – Ryan Jul 06 '11 at 19:04

3 Answers3

0
-(void)viewDidLoad
{

    rightimg.alpha=0;
    wrongimg.alpha=0;
    [scorelable setFont:[UIFont fontWithName:@"Helvetica" size:20]];

    quiz_array = [[NSMutableArray alloc]initWithObjects:@"which animal is called lion?",@"TigerDance_mov_02.png",@"LionDance_mov_11.png",@"cheethau.png",@"1",@"in these three which is the dog?",@"DogLooking_mov_36.png",@"UnicornLeggingSingleLeg_mov_09.png",@"ZeebraHeadShake_ioc_23.png",@"1",@"which animal most humans likes or pets?",@"PigWalk_ioc_08.png",@"RabbitHeadShake_ioc_10.png",@"dog.png",@"3",@"which kind of birds will keep in the houses?",@"egg.png",@"red.png",@"parrot.png",@"3",@"in these which animal are called domestic animal?",@"LionDance_mov_11.png",@"CowWalk_mov_01.png",@"TigerDance_mov_02.png",@"2",@"in these which animals are called wild animals?",@"cow2.png",@"black-horse-black_horse.jpg",@"deer.png",@"3",@"which animal moves slowly?",@"Three.png",@"turtile.png",@"snail.png",@"3",@"which animals eats veg or grass and leaves?",@"deer.png",@"dog.png",@"cat.png",@"1",nil];


    NSString *selected = [quiz_array  objectAtIndex:row];


       NSString *activeQuestion = [[NSString alloc] initWithFormat:@"%d . %@",questionnumber,selected];


    rightAnswer = [[quiz_array objectAtIndex:row+4] intValue];

    [answerimg1 setImage:[UIImage imageNamed:[quiz_array objectAtIndex:row+1]]];
    [answerimg2 setImage:[UIImage imageNamed:[quiz_array objectAtIndex:row+2]]];
    [answerimg3 setImage:[UIImage imageNamed:[quiz_array objectAtIndex:row+3]]];

        correctOption = [quiz_array objectAtIndex:(row+rightAnswer)];


    questionlbl.text = activeQuestion;

}
Ankur
  • 5,086
  • 19
  • 37
  • 62
lalitha
  • 1
  • 1
0

You can implement delegate method, viewForAnnotation as below

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation{

MKAnnotationView *view = nil; 

if(annotation !=mapView.userLocation){
    view = (MKAnnotationView *) 
    [mapView dequeueReusableAnnotationViewWithIdentifier:@"identifier"]; 
    if(nil == view) { 
        view = [[[MKAnnotationView alloc] 
                 initWithAnnotation:annotation reuseIdentifier:@"identifier"] 
                autorelease];           
    }   
    //Custom class for showing title and subtitle
    ParkPlaceMark *currPlaceMark = annotation;

        view.image = [UIImage imageNamed:@"pin.png"];

            //Button at far right corner.
    UIButton *btnViewVenue = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    view.rightCalloutAccessoryView=btnViewVenue;
    view.enabled = YES;
    view.canShowCallout = YES;
    view.multipleTouchEnabled = NO;

}       
return view;
}

Custom class for Annotation as below

@interface ParkPlaceMark : NSObject<MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *m_title;
NSString *m_subTitle;
int position;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, readwrite) int position;
-(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate;
- (NSString *)subtitle;
- (NSString *)title;
- (void)setTitle:(NSString *)title;
- (void)setSubTitle:(NSString *)subtitle;

@end

Custom class implementation of Annotation

@implementation ParkPlaceMark
@synthesize coordinate;
@synthesize position;

- (NSString *)subtitle{
return m_subTitle;
}
- (NSString *)title{
return m_title;
}
- (void)setTitle:(NSString *)title{
m_title = title;
}
- (void)setSubTitle:(NSString *)subtitle{
m_subTitle = subtitle;
}
-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
coordinate=c;
NSLog(@"%f,%f",c.latitude,c.longitude);
return self;
}
@end
jigneshbrahmkhatri
  • 3,627
  • 2
  • 21
  • 33
  • I think you missed the point of the question. I need two lines of text and two buttons, stacked one above the other, within the callout that shows when a pin is tapped on. – Ryan Jul 06 '11 at 19:19
  • try taking 1 annotation view as main view and add 2 annotation views as a subviews of that main annotation view – jigneshbrahmkhatri Jul 06 '11 at 19:26
0

Check out the Asynchrony Solutions Blog for a callout replacement implementation, though it may be more work than you're looking to do. I don't think there's a simple easy way to do what you want.

Rayfleck
  • 12,116
  • 8
  • 48
  • 74
  • While this is way more work than I'm will to do(or am capable of doing), it looks like the best answer and perhaps the only way to do something like this. Thanks. – Ryan Jul 26 '11 at 20:10