is it possible to show an annotation once the map loads in monotouch? - mapkit

I've set up the map to load an MKAnnotation when the map loads, but it will only show the pin, and not the text that I've set up inside the annotation. Is there a fake event I can call to make it show at once, or even a property?

The title property on the MKAnnotation is only used for callouts. You should call SelectAnnotation on the MKMapView object when you want it to be displayed.

Related

Open a view that only changes based on the pin that you click?

I have a problem that I do not know how to solve, I have a MapView with a series of Pin, if I click it gives me the information of local and when I click on the "i" should open a view with the information of it. The problem is this: if I wanted to open a view that changes depending on the Pin clicked?
The MKMapView delegate method mapView:annotationView:calloutAccessoryControlTapped: gives you the MKAnnotationView object that has a property annotation, which itself has properties such an title, subtitle, and coordinate.
If this is not enough to identify your annotation, you could also subclass it and give it more properties.

Catching Button Events from Different ViewControllers

My Setup
I have a ViewController, where users type some sort of text in there. Call it InputViewController.
I have a UIView (in a separate class), where I draw a navigation bar that has a gradient (I override drawRect for Core Graphics, hence I need to to have in a separate class) which has a button. The button takes you to a MapViewController, which allows you to add a location tag to your input. Once a location tag is added, I would like to change the button's image.
My Problem
Once the button is tapped, I need to send the user's input to the MapViewController, where a delegate is also implemented and will pass back some information back to the InputViewController. The issue here is that the button resides in the separate UIView. One way to do this is pass the UIView the information once they are set, which in turn would be passed to the MapViewController once the button is tapped. The problem here would be the delegate as the delegate needs to return to the InputViewController and not the `UIView.
I was wondering if its possible to move the UIView into the InputViewController, including the drawRect method for that view. If so, how can I do that? If not, what are other ways/suggestions I can do to have the above set up?
I guess you need to use NSNotifications for sending messages to your classes. See this.

Alpstein/Route-me annotation balloon

I'm using Alpstein/Route-me to work with map in my iPhone application. I want a balloon (something like MKAnnotationView, I think) to appear when I tap on marker on the map. Is there any ways to do it with Alpstein Route-me?
You would have to define a subclass to RMMapLayer. RMMapLayers are used to present annotations on the map like a MKAnnotationView is the visual representation of a MKAnnotation. A good starting point is probably the RMMarker class, which is a subclass of RMMapLayer and is used to present markers on the map.
Depending on the style the balloon is supposed to appear you might also be able to simply catch a tap on a marker in your map view controller. The map view informs its delegate about a tap by invoking
- (void)tapOnAnnotation:(RMAnnotation *)annotation
onMap:(RMMapView *)mapView
When a tap occurs you can replace the annotation by an annotation that shows the balloon.

How to access methods/variables from swapped custom view

I've created a window that contains an NSSplitView in which case the right custom view has a view that I swap into at runtime. The custom view swapped in contains a NSTableView with data inside it. I have a search box in the main window of the application that I want to be able to constrain the rows of the table view with.
I have the code to do this and I know it works, but the code I have was tested with a search text box and table view that were on the same window scope. With the text search box now being in the main window and the table view being in a different custom view, I'm not sure how to get the text search box to call the relevant methods from the custom view's controller class, because I don't have direct access to these method anymore.
I'm sure this is a very beginner question, but any help would be appreciated. Thanks.
Have your main window controller pass the search query or filter predicate to a property of the content view controller.
You can give the main window controller a weak-referencing (assign) property that holds the current content view controller. Implement a custom setter that not only assigns to the backing instance variable, but also does the swap. That, any time it's time to do a swap, you simply say self.currentContentViewController = viewControllerToSwapIn, and when it's time to change the query/predicate, you pass it to self.currentContentViewController.searchQuery (having implemented the searchQuery property in the MainContentViewController class and made all your actual content-view controllers inherit from that class).

Navigation inside UIPopoverViewController

I have a UIPopoverViewController with a UIView in it. When I push a button inside the UIView I want it to present a new UIView inside of the UIPopoverViewController. However it keeps taking up the full screen. How can I fix this?
Thanks
Create a new UIPopoverViewController inside to open the new view
Hope this helps
You have to set the content size of the popover view each time you change its content view for it to maintain your custom sizing.
Apple docs on popoverContentSize:
This property represents the size of the content view that is managed
by the view controller in the contentViewController property. The
initial value of this property is set to value in the view
controller’s contentSizeForViewInPopover property. Changing the value
of this property overrides the default value of the current view
controller. The overridden value persists until you assign a new
content view controller to the receiver. Thus, if you want to keep
your overridden value, you must reassign it after changing the content
view controller.