I have a map view with some annotations on it. I use a custom pin image for the annotations.
I am transitioning away from showing callouts to having a table view slide up from the bottom to show information about the annotation that was touched. As-is there is no way to see on the map which annotation is selected.
What I would like is to have the annotation to animate to a highlighted appearance when it is selected, and animate to a regular appearance when it's deselected, much like a system style UIButton in the selected state. How can I achieve this?
I think the easiest way is to just switch between different image files when the user taps on the annotation. I don't think you'll need to animate it - it looks fine without animation in our app.
If the user taps on an item in the tableView, you'll want to switch to the highlighted image and probably center the map at that point as well.
The only problem we've had is trying to keep the highlighted annotation view in front of other overlapping annotation views. Annotation view z-order is, as far as I know, not something that can be consistently and easily controlled.
Related
I created a custom UIView using storyboard. I don't want this at the coordinates that it is in in my storyboard, but I want to be able to reuse it throughout my app at different locations on a map like this. I also want to be able to update the text in there at the users request, and the number in there should increase whenever the green button is clicked. I also want to customize the image below it, like I learned in this question so that the user annotation has an image and this callout above it. The callout would only be there if the user has posted some text. It would look like this.
My previously linked example uses a method called setcenter to place the coordinate in the middle of the annotation, but it looks like the MGLMapView documentation and uiview documentation contain at most a setcentercoordinate function, so this is why I tried creating the annotation in storyboard instead of coding it in swift, because I didn't know how to add things to the annotation. It also doesn't look like that example show's how to constrain views to the bottom corners, like I did with my buttons (There is one view for the rocket and person button, and one view for the arrow button and the number).
Because I want to update the text field and that number(which is a label), I don't know if storyboard is the best idea to create this. I also don't know if I can use a storyboard object at a dynamic location, and create multiple of them throughout the map
After a few hours of research I couldn’t find anything related to this question.
This is what I am trying to achieve.(demo made with flinto)
My Objective
The bottom half of the screen has a view with 3 buttons on the top represented by shapes . Beneath the buttons are collectionViews (with stripes) and further down is a view at the bottom.
Every time a different shape button is clicked I need the view to be modified such that the bottom bar View appears static while the collection views change. The first (triangular) shape button also has sub buttons (represented by Aa , Bb and Cc) that can further cause the collection views to change.
Question
So my question is how can I go about this ? Shall clicking each shape button present separate View controllers or can I achieve this within only one view controller where the bottom view is modified every time I click a button.If so how?
I simply need you to point me in the right direction and I could really use some links to useful tutorials . Thanks!
.
Have you tried using segmented control?
Segmented control gives you the option to change the UI based on which segment is selected:
#IBAction func indexChanged(_ sender: AnyObject) {
switch segmentedControl.selectedSegmentIndex
{
// based on which shape is selected, you can hide/show/change color of other components here
case 0:
// triangle is selected
case 1:
// hexagon is selected
case 2:
//circle is selected
default:
break
}
}
The way I would go about this is to use only one view controller, put a stack view inside, and insert multiple segmented control inside the stack view, then manipulate them using the logic above.
Note that if you want to customize the looks of your segmented control, I would create my own subclass of UISegmentedControl where I would configure the UI.
This is what depends on what kind of functionality you want to implement in your app. Now lets be the short and sweet suppose you want only change the collectionview by the clicking each shape you can achieve it with custom tabbar view using simple UIView on single viewController. And if you want your app by adding service call and other UI elements like UITableView and many others at that time I recommended you to go with default UITabbar.
I am working on an app based on the Map View, and I wanted to implement something like Foursquare : in front of the map that you can scroll and that is linked with the pins.
I tried with the Collection View but without success.. Does anyone know how to do it or have an idea?
Thanks a lot.
You can achieve this by adding UICollectionView above MapView (use addSubview method or add in storyboard) and set background color of collection view to UIColor.clearColor. By this the collection view cell will look floating above the map view.
I have multiple markers in my google map. Each containing different information. When the user click on the marker a small view appears containing all the information. I have put up a swipe gesture on the view. What i want to achieve is that when user swipes from left to right the next marker appears in the center of the map.
**
I just need to know some logic or example. what should i implement on
swipe handler that changes the marker.
**
Gracias
Note that the swipe from left to right gesture might interfere (both programmatically as from a user's point of view) with the normal behaviour of this gesture on a map - scrolling it.
That said, you'll have to keep an NS(Mutable)Array of markers somewhere (there is no property on GMSMapView which gives you all markers). Upon detecting the gesture, find the index of the mapView.selectedMarker in the array, retrieve the next one and update mapView.selectedMarker. The map might automatically scroll to the marker, but if not, you can do this with setCamera:.
I am building a ToDo List type app, and I would like to place an editable checkbox in each cell in the UITableView. I want the user to be able to mark the item as completed by tapping the checkbox in the tableView. They also need to be able to tap in the cell, outside of the checkbox, and segue to a detail view.
So far I have created a custom cell class. The plan was to display an image of an unchecked box, and when the user taps the image, the image is swapped with a different image of a checked box (and the item is updated appropriately).
I tried putting a Touch Gesture Recognizer on the image, but it didn't work. Whenever the image on the cell is tapped, it just segues to the detail view. Then I found an article somewhere that says to create UIView nested inside the cell and link the Touch Gesture to that. So I tried that, but now it only work intermittently. Sometimes it recognizes the touch correctly, and sometimes it just segues to the detail view.
I've seen this idea in the Wunderlist app.
How do I go about implementing this correctly?
iOS doesn't have a native checkbox control. Apple uses a UISwitch instead.
If you want to follow Apple's HIG, use a switch.
If you want a checkbox style instead, you have several options.
You can attach a gesture recognizer to an image view and do it that way.
You can create a custom subclass of UIButton (MyCheckbox).
You can find a third party checkbox class that somebody else already created. I would look on Cocoa Controls. A quick search reveals half-a-dozen different checkbox options.
An important thing is the size of the "hit box" that the user taps. You usually want to create an image/view that's at least 30x30 points in size, and 40x40 points is better. An easy way to do that is to create your checked and unchecked images with enough whitespace around them to make them 30x30 or 40x40 points.
My guess is that your image view is too small and that's why you report that it is only working intermittently.