简体   繁体   中英

How can I word wrap long strings in Annotations in AppKit's mapview?

I am working with the mapview in AppKit. I have a map with pins which, when tapped, bring up an annotation with text in them. When the strings are too long, they cut off with elipses.

I'd like to make the text wrap to the next line instead of cutting off.

Here is the code.

In the .m I import the .h, synthesize the stuff from the .h. I also create the strings here. Would I create variable here that I assign the height to? Or is there a property which allows me to word wrap?

#import "AdoptingAnAnnotation.h"


@implementation AdoptingAnAnnotation

@synthesize latitude;
@synthesize longitude;
@synthesize coordinate;

- (id) initWithLatitude:(CLLocationDegrees) lat longitude:(CLLocationDegrees) lng 
{
    latitude = lat;
    longitude = lng;
    return self;
}
- (CLLocationCoordinate2D) coordinate 
{
    CLLocationCoordinate2D coord = {self.latitude, self.longitude};
    return coord;
}


- (NSString *) title 
{
    return @"Some Text";
}

- (NSString *) subtitle 
{
    return @"Some More Text, a bunch of it, a niiiiice long string. Some More Text.";
}

@end

and then in the view controller. Do I apply some attribute here?

AdoptingAnAnnotation *museumTaxiAnnotation = [[[AdoptingAnAnnotation alloc] initWithLatitude:41.891036 longitude:-87.607663] autorelease];
    [myMapView addAnnotation:museumTaxiAnnotation];

Please help! Im really new with xCode and kinda got rushed into this project.

You'll have to create your own view controller for the popover and use that when displaying. This question should help you:

How do I display a UIPopoverView as a annotation to the map view? (iPad)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM