में UIImage जोड़ें मुझे MapView के सबव्यूव के रूप में UIImageView जोड़ना होगा। ऐसा करने के लिए मैंने MapView के ऊपर एक परत बनाई। इस परत में मैं अपनी छवि रखना चाहता हूं, लेकिन मुझे एक सफेद आयत मिलता है और कुछ और नहीं। मेरी छवि दिखाई नहीं दे रही है।कैलियर
- (void)viewDidLoad
{
//......
CALayer *layer = [CALayer layer];
layer.backgroundColor = [[UIColor whiteColor] CGColor];
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
layer.bounds = CGRectMake(self.mapView.bounds.origin.x,
self.mapView.bounds.origin.y, 80, 300);
}
else
{
layer.bounds = CGRectMake(self.mapView.frame.origin.x,
self.mapView.frame.origin.y, 150, 700);
}
layer.contents = (id)[UIImage imageNamed:@"myImage.png"];
//the name is correct but in the output the image is not visible
[[self.mapView layer] addSublayer:layer];
[layer setNeedsDisplay];
}
मुझे लगता है कि setNeedsDisplay ने परत को सामग्री को फिर से निकालने और छवि को हटाने के लिए परत बनाई है। – Bastian
यह मुझे भी काम करता है। धन्यवाद एड्रियाना। –