1

私はxcodeとiPhoneの開発にかなり慣れていないので、基本的に、右端にボタンが付いた1行のテキストを含む標準のマップコールアウトを、1つのコールアウト内で2倍にすることができるかどうか疑問に思っています。つまり、これは1つのダブルハイのコールアウトバブルで、2行のテキストが重なり、それぞれの右端にボタンがあります。実際には、最初のページで詳細ページに移動し、2番目のページで注釈への道順を示したいと思います。複雑になりすぎずに、説明されているようにカスタムコールアウトを作成する方法はありますか?

4

3 に答える 3

0

以下のようにデリゲートメソッドviewForAnnotationを実装できます

- (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;
}

以下のアノテーションのカスタムクラス

@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

アノテーションのカスタムクラス実装

@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
于 2011-07-06T19:13:21.327 に答える
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;

}
于 2013-03-15T07:00:14.960 に答える
0

Asynchrony Solutions Blogで、コールアウト置換の実装を確認してください。ただし、探しているよりも多くの作業が必要になる場合があります。あなたがやりたいことをする簡単な方法はないと思います。

于 2011-07-06T19:37:40.807 に答える