iOS Overlay UI on Google maps - ios

The bars at the top and bottom are made with ImageViews, the buttons and the logo are children of a view overlaid onto the mapView as seen here:
My specific problem is that the MapView is sucking away all touch events so no buttons are working. Ive solved it by enabling user interactions on the view that contains all my overlaid controls but it disables all interactions with the map. I have also tried to wrap the ui around a view that is not user interactable with two subviews (containing the bars) that are, which ends up in weird presentation errors and a lot of NSLog'd constraint errors.
Any ideas on how to properly achieve this layout? The map is not supposed to work if the user tries to interact with it by touching the grey-ish bars.

It looks like you have a single view that holds all of the overlay elements and it is above the Map View, therefore it will handle all touches and not your Map View.
Based on this design, what I would do is create a view that contains the top section and a view that contains the bottom section. Then, place those in their locations above the Map View, this will make it so that there is no view above the Map View in the middle.
Here you see, the green section is "Top Overlay" and the purple section is "Bottom Overlay", there is no view covering the mid section of the map view where you want your user to be able to interact with it.

Related

Table View Controllers created in Interface Builder have their bottom cells clipped and obscured on iPhone X

If a Table View Controller is created using Interface Builder, on iPhone X the lowest visible cell will be obscured by the home screen indicator, and the cell's corners clipped by the curved screen, by default - see screenshot below.
If I use a View Controller and insert a Table View, then set it up by hand, I can use the bottom layout guide with the table view, to ensure this obscuring and clipping behavior doesn't happen, i.e., by not allowing the table view to extend into the curved part of the screen.
I'm upgrading a few legacy apps, and I'd prefer not to have to convert the existing Table View Controllers into View Controllers if possible. How can I make Table View Controllers created with Interface Builder behave?
According to the Apple docs, by using the standard interface elements this shouldn't be a problem.
Inset essential content to prevent clipping. In general, content
should be centered and symmetrically inset so it looks great in any
orientation and isn't clipped by corners or the device's sensor
housing, or obscured by the indicator for accessing the Home screen.
For best results, use standard, system-provided interface elements and
Auto Layout to construct your interface. All apps should adhere to the
safe area and layout margins defined by UIKit, which ensure
appropriate insetting based on the device and context.
If you enabled automaticallyAdjustsScrollViewInsets, table view will be upon home indicator when you scroll to bottom. I think this is what Apple wants, take advantage of the full screen at the same time every elements can be interacted.
If you want cells never obscured or clipped in UITableViewController. I suggest you use plain style table view, set contentInset to make section footer hovered under home indicator. I tried this, It worked but looked ugly. Like this:
In the end, I converted the Table View Controllers into View Controllers and added a bottom alignment constraint to the Table View

Having a subview inside of another view

My SCNView is full screen, but I would like to add a view in the bottom right corner like a minimap of a game. I have the code working separately in each of the views, but I have no idea how to view both of them at the same time.
If possible, I would also like it so that if the smaller view is touched, the position of the two views are swapped (the main view becomes the mini-view, and the mini-view becomes the main view) -- which could be repeated as needed to swap them out.
SCNView is a subclass of UIView so you can treat it like a regular view. There are too many different ways to handle this to cover them all. But for example, use addSubview to add one to the other. You could for example also use a popover view in the first scene, and add the minimap sceneview to the popover.
To swap them around you can use one master view (like the one of your main view controller) and then add the first sceneview, and to that sceneview add the mini map. When you tap the mini map you can simply remove them from their parents and add them again in the desired hierarchy. Another option would be to add both sceneviews to a master view and resize them and then use sendSubviewToBack on the sceneview that was the minimap.

How do I add an overlay that does not move with the map to a GMSMapView?

I'm trying add a crosshair in the middle of a GMSMapView. The crosshair will not move with the map as the user pans it. It will move with the camera.
I looked at the google maps guide but it doesn't seem to talk about the kind of overlays I'm interested in. What it says is just adding overlays and shapes that moves with the map.
Therefore, I tried to come up with something on my own. I tried to add an UIImageView on top of the map view he storyboard. (Note that both the image view and the map view is in the storyboard and they are both direct subviews of the view that the VC controls)
When I run the app, I did not see the crosshair anywhere on the map. I looked at the UI hierarchy and saw this:
The little view is the image view with the crosshair, and as you can see there are 3 more views in front of it. I think this is why the crosshair did not show. The three views are, from right to left: GMSVectorMapView, GMSUISettingsPaddingView and GMSUISettingsView.
I have not idea how to bring the image view to front. I tried bring it to front by calling bringSubview(toFront:). I tried to call this in both viewDidLoad and viewDidAppear but it did nothing in both times.
How can I make such an overlay work?
You can use zPosition to achieve this
YourView.layer.zPosition = 1
by doing this you will put your view's layer to the frontmost position, but not the view itself. So position of the view won't change.
self.view.bringSubview(toFront: YourView)
Should also work, it's probably juat a timing problem.

PageControl placing the marker in the position I want ios 9

I am creating a screen of an application that contains inside a custom cell one pageControll. It is already working properly but by default his marker comes down the contentView. How can I make the marker in the position I say? In case a little but within the above contentView
this is my screen:
I can think of two possible solutions.
Instead of adding the pageControl to the the cell's content view, add it instead as a child of the red view you have there.
In interface build add a constraint between the bottom of the content view and the pageControl.
Either should achieve the result you're looking for, if I understand you correctly.

Drag MapBox map on different UIView (iOS)

Our UIView contains a MapBox map. At certain moments during our apps lifespan we display a UIView on top of the Map.
This view had a transparant background and a couple of controls inside it. What we want is to be able to drag the map on the spots where the view is transparent. (It should basically pass through the gestures to the view below it..which is the map).
To get a basic picture of what we try to accomplish: think of a map and above it is a view which shows a big + sign. What we want is when we drag the actual sign...nothing happens. But when you drag in the empty corners, it should drag the map.
Any ideas how to accomplish that?
Check out -[UIView userInteractionEnabled] and set it to NO for the transparent view. Be sure to set it to YES for the control subviews. That should do the trick.

Resources