views:

326

answers:

1

My iPhone app shows the user some massive images, I've successfully tiled them and used a UIScrollView to allow them to pan around and look at parts of it in detail. Now I want to draw points above that background image and have them move around when the user pans/zooms, essentially like placing a pin on a notice board. I don't want to mark the image permanently and I may need to move it or add more of them. My first attempt id the code below, thinking I could just plonk it into a subview at it would appear in the corner, then I'd worry about offsetting it from the origin and stuff like that. Using this code I can't see my marker anywhere within the UIScrollView so I'm looking for help.

myContentView = [[UIView alloc] initWithFrame:imageRect];
UIImageView *imageView = [[UIImageView alloc] initWithImage:marker];
[myContentView.layer addSublayer:tiledLayer];
[myContentView addSubview:imageView];
A: 

What I would do is make another UIView *mapView that is the same size as myContentView to hold the tiledLayer, and have both the imageView and new mapView at the same level instead of one being a subview of the other.

myContentView = [[UIView alloc] initWithFrame:imageRect];

UIView  *mapView = [[UIView alloc] initWithFrame:imageRect];
[mapView addSublayer:tiledLayer];
[myContentView addSubview:mapView];

UIImageView *imageView = [[UIImageView alloc] initWithImage:marker];
[myContentView addSubview:imageView];
lucius
I modified the third line to get it to compile but I see no change on the UIScrollView at all. The background image still appears but nothing is draw over it. I've also reversed the order of the subviews incase it was being drawn under it, but no luck. Just to proove I was getting the right marker I tried setting it as the image of a button that is on screen at the same time and it comes out all white so there is a problem at that end but since there are no large white squares appearing over my background image I think I am still not drawing into that scroll view
Craig
The edit was to make it [mapView.layer addSubLayer:tiledLayer];
Craig
Apologies, the error was elsewhere in my code. All your suggestion needed was that little .layer thing and it solved my problem. Thank you.
Craig
Glad to be able to help!
lucius