IOS Google Maps Different Custom Info Window For Each Set Of Markers - ios7

I have two different set of markers displayed on my google maps on IOS.
I have seen many samples to show a custom info window when a marker is tapped.
I need to show different custom info window to be shown for each set of Markers.
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
// How do I identify which info window to show from GSMMarker ???
if(marker type is 1){
show this info window1
}else if(marker type is 2){
show this info window2
}
}

Related

Implementing context menu for NSTableCellView

I have a table view where I would like to have a different context menu appear when right-clicking on a cell vs. when right-clicking on an area where there are no cells. I'm trying to do this using storyboards in the interface builder.
If I attach a menu to the NSTableView I can get a context menu to appear. However, if I attach a menu to the NSTableCellView I get the NSTableView's context menu rather than the menu I have attached to the NSTableCellView.
I know I could do all this via code by having one menu attached the the NSTableView and change it's contents based on the cell clicked but I believe I should be able to do this by attaching different menus to different views in the view heirachy.
Can this be done solely in interface builder?
As per Willeke's suggestion I sub-classed the NSTableView and added the the following code to the menu property:
- (NSMenu*) menu
{
if (self.clickedRow == -1 || self.clickedColumn == -1) return super.menu;
NSTableCellView *clickedCell = [self viewAtColumn:self.clickedColumn row:self.clickedRow makeIfNecessary:FALSE];
if (clickedCell != nil) return clickedCell.menu;
return self.menu;
}
With this implementation I get the behavior I was looking for.

NSDocument-based app window position

My Xcode NSDocument-based app contains a floating panel. On each launch of the app the default doc window and panel appear in their previous locations on the screen. However, if I save a document and quit the app then double click the saved file, the document window is positioned at the same origin as the panel.
Turning off cascading gets around the problem but of course I lose cascading.
A minimum Xcode example showing the issue can be downloaded here.
Run the example project.
Do a File/Save.
Quit the app. << important
Double click the saved file.
Any help appreciated.
If you want to store the state of your window before the app terminates try this:
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
// If you want to save your window position
// you can use [window saveFrameUsingName:#"someWindowName"];
//
// then use [window setFrameAutosaveName:#"someWindowName"]; at the app launch.
return NSTerminateNow;
}
I knew it had something to do with document windows cascading from the panel. Adding this to the panel controller seems to have fixed it
- (void)windowDidLoad {
[super windowDidLoad];
[self setShouldCascadeWindows:NO];
}

iOS7 Keyboard Behavior with SearchBar/UITableView: Offset on secondary view appearances

Problem
I am having a rather big issue with the iOS7 keyboard appearance. I have a Searchbar on a UIViewController with TableView Delegation/Data Source setup (I am using the self.searchDisplayController delegates as well). I segue from this scene to a prototype tableview to show the results.
Here is the issue:
On first load I can see the keyboard being displayed when I tap into the text field of the UISearchBar. I can type and perform a search with the results being shown in the next scene.
I've added NSNotifications to view the keyboard properties in local methods keyboardWillShow and keyboardWasShown. I can see on the first scene appearance (after the view is completely loaded):
I segue to the result tableview at this point and when I navigate back and touch the text field, my keyboard shows up either fully or partially off-screen:
When I look at the keyboardWillShow notification at this point I can see that my keyboard values are incorrect:
I've researched and tried many possibilities including:
Added the following to my main view controller:
-(BOOL)canResignFirstResponder
{
return YES;
}
-(BOOL)canBecomeFirstResponder
{
return YES;
}
Configured the following in my view did load
self.searchDisplayController.searchBar.spellCheckingType = UITextSpellCheckingTypeNo;
self.searchDisplayController.searchBar.autocapitalizationType= UITextAutocapitalizationTypeNone;
self.searchDisplayController.searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
self.searchDisplayController.searchBar.keyboardType = UIKeyboardTypeDefault;
Put in standard stubs for:
-(void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
I've noticed that if I choose a Partial Curl as my segue mode, the keyboard remains accessible when I roll back to the main view controller (but then it was never fully off screen in that case). However if I move from the results tableview to a detail scene and then navigate back to the main view controller, the keyboard appears off-screen again.
Question
Is there a method I can use to intercept the misplaced keyboard so that it displays in the default location?
NB: Along these lines, I have created a NSDictionary property to hold the initial userInfo values with the correct keyboard placement. I am not sure how to reassign these values to get the keyboard to return to it's original placement.
BTW - This seems a bit of a hack to get the keyboard fixed due to a bug in IB, is there some other way that I can try to remedy the situation?
Thanks in advance for any feedback!
Solution
This was such an obscure issue that I'm sharing the solution to save the next person some effort. Like most programming issues, it turns out this one was self-inflicted. In my original iteration of this project I had turned off rotational support as I am learning auto-layout and I wanted to ease into the transition from Springs and Struts. Somehow between the start of the project and the code release I ended up with this bit of code in the Main Scenes' View Controller.
//BAD
- (NSUInteger) supportedInterfaceOrientations
{
return !UIInterfaceOrientationPortraitUpsideDown;
}
instead of returning a valid enumeration like...
//OK
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}

IOS MapView callout resize

Currently I'm working on the ios mkmapview to show some pois with pin added on the map, when user click the pin, the default callout will come up and show the title of the poi, but some of the titles are quite long and the callout is not wide enough to show the title completely.
What I want is just make the callout wider, how can I do it?
I searched for answers for hours but all are about implementing custom class for callout, is there any way to just re-size it without further implementing?
Do I miss something obvious?
Im doing almost something similar. Because i don't like the normal callout on the map I created a custom callout. Implement the MKMapViewDelegate in your header and declare the method (void)mapView:(MKMapView *)aMapView didSelectAnnotationView:(MKAnnotationView *)view in your implementation file. In this method i create a new view which displays the content of the annotation. Add a UIButton to close this custom view.
//deselect the selected annotation
- (void)deselectAnnotation {
selectedAnnotation = mapView.selectedAnnotations;
for (int i = 0;i < selectedAnnotation.count; i++) {
[mapView deselectAnnotation:[selectedAnnotation objectAtIndex:i] animated:NO];
}
}

textbox in Mapoverlay/ textbox in custom view to display on a map

I am kind of new to IOS app development. I have a map view and when a user taps on the MKMapView, i want to pop a text box there so that user can tag the place. I figured out the part on how to handle tap events on map. But I couldn't really understand how to get the textbox up there on map. I think I should use overlays, but I am not sure how to put a text box in an overlay. Can someone please give me sample code to put textbox in overlay?
Here is my code which handles tap events and this overlay display might have to go in the if loop.
-(void)handleTapOnMap:(UITapGestureRecognizer*)sender
{
if (sender.state == UIGestureRecognizerStateRecognized)
{
NSLog(#"Tapped on the map");
return;
}
else {
return;
}
}
If you want to add custom overlays you can see this project on overlays on github
Or if you want to add the overlay yourself you will have to create a custom view and use the delegate method :
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id )overlay
{
yourOverLayView *view = [[[yourOverLayView alloc] initWithOverlay:overlay] autorelease];
return view;
}
You can also go through the mkmapview tutorial :