iOS Map pin bubble out of screen - iphone

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.

Related

Zoom An Entire View Controller

I have an app im working on. The main view controller has a keypad ( like on a safe door). I want the user to tap on the numbers pad and i want the whole view to zoom in. This is not a UIImageView. I know how to zoom an image/imageView. I want to have a super small set of numbers/number pad, and a super small textfield, then when it zooms in, those two UI elements will be big. I would like to have this done via button press!
Thanks in advance. I have no code to provide! Sorry, And Thanks :D
One possibility is to just make an imageview, zoom this to your desired size, then hide it and "replace it" by the real number pad. To do that just have the number pad hidden at the beginning and visible, once the image view reaches its final size and disappears (just hide it then)
To the user it all looks as if the "number pad" will zoom - which is actually your image of the number pad.
Also to have only one View to hide/unhide just put your all your keys of the number pad and whatever else on one container view.
To get the image to be zoomed, just make a screenshot and cut out your zoomable image area with some kind of Photoshop tool.
By the way, I would expect your idea of a zooming number pad will surely be a nice animation in your app!

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.

Proper way of showing/hiding map overlays

I have a custom overlay that trace the user location changes. I want to show/hide the overlay. What's the proper way of doing that?
I'm using hidden property of overlay view to show/hide it right now, but it doesn't work very well. When i pan and zoom on the map i see bits and pieces of overlay (even when i've set hidden property to TRUE).
Instead of showing/hiding the overlay, i ended up adding/removing the overlay which seems to be working fine (in most cases).

Cannot move the MKMapView from a centered position?

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.

iPhone SDK: disabling cllipping for UIScrollView

I'm working on an iPhone game, and trying to use a UIScrollView to display some icons, which I then want to enable the user to drag off the bar being scrolled, onto another view (basically, dragging them from their hand into play on the game board). The problem is that the UIScrollView clips everything outside it's own bounds.
Here is a picture of what I'm trying to do:
Functionally, it actually works, in that you can drag the icons up to the white board fine...but you can't see them as you are dragging...which is not acceptable.
Does anyone know if you can temporarily disable the clipping that a scroll view does, or is there some way to get around it? Hacky or not, I would really like to make it happen.
Does anyone have any other possible solutions for this? Or maybe any alternate approaches? I've considered if maybe a page view might work, but haven't tried it yet...and it's not at all as good of a solution as the scroll view.
Worst case I can just go back to not having the bar scrollable, but that really puts a damper on some of my game mechanics, and I'm really not too excited about that.
I think you're looking for the clipsToBounds property of UIView. I've used it successfully with UIScrollView:
scrollView.clipsToBounds = NO;
However, the dragging you want to do from the scroll view to the game view may require you to remove the icon view from the scroll view, place it in the superview at a position corresponding to its visible position within the scroll view (calculated using the scroll view's origin and content offset), and have that track the user's finger movements. On a release of the touch, either drop it on the game view at the proper position or return it to the scroll view.
I'm not 100% sure I understand the question but I think you should look into the z order of the scrollview and the whiteboard. It may be that the drag is just going behind the whiteboard.
Failing that, it would be useful to see all the bounds of your view heirarchy.
I also think a better solution allround might be to create a "sprite" to animate underneath the players finger - you could offset the drawpoint of the sprite from the touchlocation so that the player can see what they are dragging.