2

am using the following image [using Annotations, MapkitView etc], to mark some locations. But, when the images are displayed, they appear 2X bigger. Is this normal?

Here is an inherited class, that I use

@interface ImageAnnotationView : MKAnnotationView {
        UIImageView *_imageView;
        id m_parent;
        BusinessMapAnnotation *m_annotation;

        NSString *stitle;
    }


    - (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
        self.backgroundColor = [UIColor clearColor];

        self.m_annotation = (BusinessMapAnnotation*)annotation;

        self.stitle = m_annotation.sTitle;
        _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:([stitle isEqualToString:@"You are here"]) ? @"Pushpin_large.png":@"NearPin.png"]];
        _imageView.contentMode = UIViewContentModeCenter;

        [self addSubview:_imageView];
        _imageView.center = ([stitle isEqualToString:@"You are here"]) ? CGPointMake(15.0, -10.0):CGPointMake(kWidth/2, 0.0);

        return self;
    }
NBALA
  • 17
  • 4

1 Answers1

3

If your images are made for retina-display quality resolution but do not have @2x appended to the end of the filename (i.e. 'Pushpin_large@2x.png' as the file name in your project folder) then they will appear two times larger when drawn. If this is the case, don't change your code, just append @2x to the filename.

Matt
  • 1,563
  • 12
  • 13
  • Thanks Matt, how do I know, whether the images are for Retina display? – NBALA Aug 04 '11 at 07:16
  • For others having the same question[link] http://stackoverflow.com/questions/4800467/retina-display-images-on-iphone – NBALA Aug 04 '11 at 13:35
  • 1
    Retina images are twice the resolution of non-retina images. So if an image appears twice as big as it should be, then it is probably a retina image. – Matt Aug 04 '11 at 15:04
  • Thanks, Matt. Spent ages trying to find why this is happening, your answer fixed it! – jskidd3 Nov 24 '14 at 17:00