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
Related
I'm trying to do something like the following:
As you can see, a popover shows up as you start typing, and updates the results as you type. My question is regarding the UI and how to actually implement it.
How can I show a custom popover when the user starts typing? Is it possible to load a custom view into a popover? Additionally, what would I need to do if I wanted to also include an image view in each typeahead result?
Good question, which most beginners have. Follow my instructions given below.
First create a view controller and design it as you wanted it to be and include a Search Controller and implement it's delegate functions in the view controller.swift file(Hope you know to work with delegates for controllers,else just google it...It's pretty easy).
Then add a Tableview in center of the view for viewing the results like shown in your question & and add a custom cell into the table view and then setup a custom class file for that cell exactly like how you works with tableview controller.Use just the basics of tableview stuffs.
Setup outlets and all for the controls and buttons.
Create an array named 'filteredResults' or name it as you like to reload the tableview data whenever the text is changed in search bar.
To detect and call your function while user changes text in search bar,You can use didTextChanged delegate function of search bar.
Note though that it's better to find everything else by your own so that you feel confident about yourself when you solve the problem at the end.
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.
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.
Using UICollectionView and excellent help given on here on StackOverflow, I've been able to build a "Gantt Chart" style control for my iPhone:
Cosmetics aside (I'm doing the functional right now, I've got a graphics designer on tap to look at colors and all that).
Background aside, the spans were relatively straightforward to do with a custom UICollectionViewLayout subclass. Each span is an item.
But I need to add some functionality, and am unsure how to proceed. Where I'm trying to go is illustrated roughly as:
Sketchy cosmetics aside, the point is that I want to "annotate" whatever the currently selected span is with additional information (I promise to find someone to help me look it pretty). And I want them to be active, I'm not sure if it brings up an editing control or does drag, but I want to be able recognize gestures on either the numbers or the bold lines and do things with them, distinct from touching on the span which drives selection.
I can think of (at least) 3 ways to try and implement this:
Use supplementary views. Cause selection to invalidateLayout, detect the selected state in my prepareLayout, and generate additional layout attributes for the two anchors. Implement a subclass of UICollectionReusableView which does the drawing, and adds touchable subviews (or its own gesture recognizers). This feels... wrong. I get the idea that supplementary views are more for headers and footers, not for controls that come and go as the selection state changes. But maybe it's an appropriate extension of the facility?
Use the backgroundView (or selectedBackgroundView, not sure it matters) of my current SpanCell class (which is a subclass of UICollectionViewCell). As long as I disable clipsToBounds, I can draw the annotation around the bounds of the span. I'll have to give it some knowledge of the big picture to find the endpoints, but that's not too offensive. I would just show/hide this view in response to selection changes. This seems like the best way to do it.
Do it in the main backgroundView of the entire UICollectionView. As shown, I've already got a specialized backgroundView which shows the the current time grid, strip style. I could further extend this view to draw annotations and manage touchable sub controls in response to selection changes. This would give me most direct implementation, but it feels like I'll end up with a big monster "doing too many jobs" object for the background.
Question then, for those who have more experience, is which route would you go? Would it be one of the above 3? Or something different? And why?
While your question is very technical with UICollectionView implementation, which I am not very familiar with, this seems like a job for the container (in this case, the collection view). Imagine you need your annotation to consider, in addition to the selected item, other items? Like for example, avoiding collision between annotation lines and another item?
For me, option number 3 seems like the most correct one. If you fear a large class, you can extern it to an annotation controller class, which should be notified whenever the annotations should be updated.
Quite simply, I'm trying to add multiple buttons to the bottom of the static table view, much like in the address book app (below the contact's details for Send Message, Share Contact and Add to Favourites). However it just simply won't let me add three button in Storyboards unless I use a subview but then I can't quite get the colour to be the same as that of the iOS 6 background (and I've used the colour picker). What happens is that it'll simply add the button below the table view section and it takes up the entire width of the iPad's screen.
My other (and original) thought was to use the static table view cells to simply call methods. What I want to do here is add the building's details (like address, name etc) to the user's contacts app when they press the tableview/button - but I can't link it to any IBActions.
Using a button would be no problem, so if the first issue could be solved that'd be excellent.
If you use the solution with the subview, you can set the views backgroundcolor to [UIColor clearColor]