Callout accessory on tapping images - iphone

I have some images in my viewcontroller's view. When I tap on each image I need to have a callout accessory, just like the one we get when we tap on a pin in the mapview. I read that this is normally used on annotations in mapviews. Could this be done on images in a view. Need help.

You can make your own custom view similar to the annotation in mapview. That you can add on the image on tap and remove that view when you tap again somewhere.

Related

How to create a message box when user press on an image in swift ?

I am trying to do something like this picture.
https://i.stack.imgur.com/5JneD.png
So when a user press at a specific area in a box, a button or a message tag will appear.
Any idea where should I start from? I was able to create the box, just need when the user press a tag appears.
Add a UIImageView to your view controller. Set isUserInteractionEnabled to true for the image view. Attach a UITapGestureRecognizer to the image view.
In the handler for the tap gesture recognizer's tap handler, call location(in:) to get the coordinates of the tap in the image view's coordinate system.
Use the CGRect function contains(_:) to determine if the tap point is inside either of those areas.
Note that alternately you could simply add transparent buttons on top of your image view at the desired locations and use target/actions on those buttons to respond to the taps.

Adding UIButton to UIImageView within UIScrollView on Swift

I am writing an application for an event my organization is hosting using Swift. I have an image with the floor layout and want to add buttons to select locations (such as bathrooms, entrances, exits, emergency sections, etc) so that people can click them and information about the location pops up.
I currently have an imageview with the floor layout within a scrollview to allow the user to zoom in and out of the image. When I try to add buttons to the scrollview they don't stay relative to the image when zooming in and out, nor do their size change. I have tried adding constraints on to make the location stay the same when zooming in and out.
It also won't let me relocate the button on the storyboard to be a subview of the imageview. Looking up similar solutions says to add the button programmatically as a subview of the imageview but then it'd be really hard to put the 100+ buttons in the right location. Any suggestions as to how to go about this?
you have no other choice instead of adding by code.. because from code you can add as subview of image view , whereas Storyboard wont add buttons as subviews of imageView, but it will add buttons as subview of Scroll View

Adding a Stationary Button Overtop of a Map View

I have a really quick question which is probably ridiculously simple. I currently have an application that I am using route-me and OpenStreetMap, and basically I have a view that loads the map into the entire window.
When trying to run the project with a button added to this view in Interface Builder, the map loads overtop of the button, and is not displayed.
The map view is loaded by a custom class RMMapView (route-me class), and I already know how to add markers to the map itself, but not a stationary button in the corner of the screen that won't move as the user drags the map around. I want to add the button as an overlay, a view overtop of the map view itself.
If you guys could give me any tips on how to do this I would greatly appreciate it.
Thanks.
[mapView bringSubviewToFront:button];
Maybe this helps.
Add the mapView as a subview to a view, and add the button as a subview to the same view.
In Interface Builder, on the left side pane that has all the scenes, switch the positions of the button and the MapView. If the button is listed above the MapView, drag it down so it's below it.. or vice versa. This will change which view is on top of the other.

iPhone Setting A Background Image

I want to use an image as a background for my application. I want the buttons to be over the image. How is this accomplished? Everytime I use image view it covers up the buttons.
The image view should cover your buttons unless you are placing it higher in the list of subviews. Make sure your image view subview is added first and the buttons (and all other views) will be displayed on top of it.
Are you doing this in Interface Builder or manually in code?
You could try using UIView's sendSubviewToBack method:
UIImageView view = / init view */;
// some additional code here
mainView.addSubview(view);
// add buttons, etc...
mainView.sendSubviewToBack(view);

Setting up the (right) views in order to show an image, the details of it beneath it and enable zooming for the image

What I am trying to do is to present an image at the top of the view and beneath it to show the details of it.
By now I am using a UITableView and a UIImageView. The UIImageView is at the top of the View and the UITableView beneath the UIImageView. In the UIImageView I load an image and I want to let the user to pan/zoom it. In the UITableView I show in sections the details of the image. Everything works ok, but when I enable zooming in the UIImageView the image covers parts of the tableView. Moreover, I cannot scroll anymore.
What is the correct combiantion of views for achieving the above requirements?
Instead of the UIImageView I'd use a UIScrollView with the UIImageView embedded in it, this will allow you to setup pan/zoom within whatever view size you want.