Cannot move the MKMapView from a centered position? - iphone

I am working with creating a simple iPhone app to show a map and some labels, however the MKMapView likes being centered when I put it in the interface builder.
I am very new to this, so i apologize for my ignorance.
I cannot seem to find a way to move the MKMapView from its centered position. I can scale the edges, however the scaling is mirrored on both sides and it does not let me alter the x and y value manually. I want to move the MKMapView to the top of the screen and have some labels on the bottom, however I don't want any extra space at the top.
Is there any method I can use (either within the Interface Builder OR in the actual Objective C code) which will let me move the MKMapView more freely?
Thank you,
-Serge

It sounds like you're attempting to place it in a bare window. If you want to position it on a portion of the screen somewhere you'll want to place a regular View in the window first (that could just fill the window), then put the MKMapView on that view. You'll be able to move it to wherever you'd like.

Related

UIPopoverController in application window

I am creating a UIPopoverController from the application delegate and I want to center it on the window, how ca I do that?
You can specify the rectangle that it is anchored to when you display it. Just specify an rectangle and direction that guarantees it will be displayed in the position you want.
It does sound like you may be doing something that would be best done by presenting a custom UIView as a new subview instead of using a popover. The popover will always have the little arrow coming off the side.

Can we Add a new layer over CATiledLayer?

I am displaying a big image in CATiledLAyer.
Now i want to draw a line between two points where the user touches on that image.
Would that be possible ?? , if so can you outline me the way to accomplish it ??
Thanks,
Ratna
I did something similar for an app a while back. The strategy I used was to place another view on top of the view with the tiles. Then set your self up as a UIScrollViewDelegate and everytime the tiled view scrolls or zooms, recalculate where the overlayed objects need to be. Just read the contentOffset value and the zoomScale and you should have what you need to correctly figure out where your overlay needs to be positioned. You will also have to make sure that touches are correctly reaching the tile view if they have to pass through your overlay view.

iOS Map pin bubble out of screen

When i click on a pin on the map and if the pin is on the borders of the iPhone screen, the bubble comes off the screen, i.e. Half ourside of the viewport and half inside the viewport.
Is there is any property etc which will show the bubble automatically centered on the screen.!
Check this image below to know more about what i mean
http://i.stack.imgur.com/ZSWmZ.png
Any help will be highly appreciated.
You can try to make it so that everytime an annotation is selected, you change the map's center coordinate to the coordinate of your annotation? Instead of calculating the pop up view's dimensions, just do it every time instead. Here's the code to do this. Put this into your delegate for MKMapView
- (void)mapView:(MKMapView *) theMapView didSelectAnnotationView:(MKAnnotationView *)annoView{
[theMapView setCenterCoordinate:annoView.annotation.coordinate animated:YES];
}
Once you've done this, you should be all set.
Also, it's curious to note, that when I tried implementing a mapview, and I added annotations, whenever I selected them, the map automatically moved so as to display the whole calloutView. I wonder why yours isn't doing that. Anyway, if my answer helped, please accept it as your answer. Thnx
Mapkit does a great job of positioning the map when annotations are selected but it can't magically account for other UI elements you've placed in the scene that are obscuring things.
You need to either resize your mapview when your search box is down so it is not obscuring it or you need to add logic to reposition the map if a annotation is selected which is near the top of the view when the search box is visible.

How can I specify where I want my UI elements to go on orientation change in Interface Builder?

Ok so I know this is a bit of a newbie question, but being that I am a newbie its ok! I have a view that I am trying to make orientation friendly in IB, and I am having some difficulties.
I have everything looking nice in portrait of course, but then when I go to landscape mode (by hitting that arrow in the top-right corner) everything gets all messed up.
Now, because of the way the view is laid out, I need to align 3 buttons along the bottom of an image view in portrait, and then in landscape, those three buttons need to be symmetrically aligned along the right side.
No combination of fiddling with those red arrows in the size inspector are rewarding me the results I am seeking. Is it possible to set up the buttons one way in one orientation in IB, and then on change, set them completely different?
I have looked all around for a useful IB tutorial, but haven't been able to find anything.
I know you want to do this in IB, but if you're willing to try it programmatically, then you can move things around pretty easily. For your buttons, just implement the setCenter method like this:
[myButton setCenter:CGPointMake(xCenter,yCenter)];
Otherwise, if you want to use the IB, use the Autosizing options. The arrows will stretch or compress the width and height, and the bars (|-|) preserve distances from the top and bottom. If you have three buttons in a row, you can fix the left distance for the left button, the right distance for the right button and both/neither for the center button. Something like that may work.
The third option is to make a new view, call it landscapeView or something, by dragging a UIView from the library to the window with File's Owner, First Responder, View, etc. Then orient that to landscape, copy over all your UI objects, lay them out as you like, and when you rotate, replace the current view with landscapeView. The problem with this that I've found (one of many) is that you have to reconnect everything and have different IBOutlets for the labels and whatnot. T
Using IB's autosizing features can only do so much. PengOne does a good job of describing them in his second paragraph. If they are not enough, you have to move the elements programmatically. See Responding to Orientation Changes. Otherwise, you can just use a completely different view, again as mentioned by PengOne.

draw line/point on existing UIView without drawRect?

I created line chart. Now I need to display point on this chart when I tap the screen.
What would be the best method? Do I need to call drawRect method again, draw whole chart with marked point?
I'm thinking about something like transparent layer over the chart UIView.
Can I create another transparent UIView and put it on the position of my chart?
Since all drawing is done in a view's drawRect: you can only optimize your chart's drawing so it can be made to update only a part of it and use setNeedsDisplayInRect: (passing the area where the marker should be).
Or you create another UIView subclass that is layered atop of your chart and that does nothing but drawing the markers on a transparent background. Probably easier and faster to implement. It also would have another benefit:
If you make that view only as big as the bounding box of the marker you could also easily animate it, like fading it in and out. Or letting it rotate a little (to see the effect I have in mind, select the "Help" menu in Mac OS X, type something in the search field like "a", and see the marker next to a menu item move a little around a spot).
You can draw a portion of your view using setNeedsDisplayInRect:.