Using MonoTouch.Dialog I create a table of values.
When the user clicks a row, the row should flash blue as per normal.
How do I enable this in MonoTouch.Dialog?
MonoTouch.Dialog supports the flashing behavior for Elements that can actually respond to events (like the StringElement when it has a tap-handler attached) or other elements that need to respond to the user's interaction.
This is done by setting the SelectionStyle property on the cell to UITableViewCellSelectionStyle.Blue
Most of the cells that do not respond to user's input have the value in MonoTouch.Dialog set to None. You can either change the source code to make it use Blue everywhere, or make sure that you are using the right Element for the right use case.
I blogged about some design patterns for building Elements recently, if you want to roll your own:
http://tirania.org/monomac/archive/2011/Jan-18.html
Related
I'm using Voice Over in my application. I'm having hard time to figure out which table cell is currently selected when voice over is on. How can I know whenever user initiates single tap or navigate through any tableviewcell?
These are the things you can try:
use the UIAccessibilityFocusedElement global function
override accessibilityElementDidBecomeFocused and accessibilityElementDidLoseFocus on the cell
observe the UIAccessibilityElementFocused notification in NotificationCenter in situations where you need it (e.g. when the view controller for the table in question is showing)
Also what element will report focus will most probably depend on whether your UITableViewCell has isAccessibilityElement set to true or false.
While the above will probably help you with literally what you asked, it is also possible that your overall approach to accessibility in this situation might be wrong if you need the above information. If you share more info on the bigger picture / motivation what you are trying to achieve, it might turn out that the information about focused element might not be needed at all and that another solution is more proper.
If what you need is to add a hint for swiping, you can simply set accessibilityHint on the proper element (if you set isAccessibilityElement = true on the whole cell, then set that on the whole cell, otherwise try setting it on the label that VoiceOver reads in the cell), e.g. when you configure the cell for display (usually in tableView(_:cellForRowAt:)). In such case, you will not need to observe which element is focused, and simply let VoiceOver read hint available on that particular element/cell.
I've got a bit of a weird situation. I need to have an element not be read out by VoiceOver when I use the 2 finger swipe method, but to be read when tapping on it still.
The object is part of a TableView cell, and I've given the TableView cell its own accessibilityLabel, because it contains two interactive elements, one of which doesn't actually need to be read when tapped on, so I've disabled its accessibility property.
However, my other one needs to be read still when tapped on. The issue is, it's already being read as part of the cell's accessibilityLabel, and then it is read again because it is still an accessible element. Is there any way to differentiate between why VoiceOver is reading an element? Or to dynamically change the accessibilityLabel?
You can dynamically change accessibilityLabel simply by assigning it or overriding the method on the accessible view. However, you shouldn't rely on VoiceOver respecting the change in real time.
Users can navigate via tap or swipe and expect elements to persist regardless of how they were reached. In general, I discourage clever solutions that assume how users interact with VoiceOver.
I'd encourage you to either override the cell summary to omit the label or disable accessibility on the label and leave the content in the cell summary.
I'm totally new to App design for iOS. I am designing an iOS app with Swift. I have a RESTFul service that returns a list of Cities based on a partial string query. My webapp uses Jquery-AutoComplete to perform the operation and it works great, I was wondering how I can achieve the same drop-down list look with Swift.
Here's how I retrieve the data. If the size of UITextField is greater than 3 characters, my App Starts sending the content of the UITextField to my RESTFul Service and get back the list of cities that start with those characters (My service returns the top 10 matches).
My challenge is, how can I show a drop-down under the UITextField just like JQuery-AutoComplete list ?
From comments above:
I would use a UITableView underneath your UITextField, which you would then populate its data source with the response from your web service.
does it integrate seamlessly ? I mean when there is no data it hides automatically or I have to track its visibility ?
You can set the hidden property of the table view depending on whether there is anything to display from the web service response. If there is no data set hidden to TRUE, if there is data set it to FALSE and use the reloadData method to reload the table views data source.
Thanks. So one last question, If I have stuff under the UITextField, when I set the visibility of UITableView, is it going to appear over the background and elements under the UITextField or it's going to push them down and rearrange the UI ?
This all depends on how you set up your UI. I would add the table view as a subview of the main view which would add it above any other objects. Again, however, this would depend on how the rest of the UI is set up. You can use the insertSubview: aboveSubview: method to make sure the table view is above all other views. Setting the hidden property of the table view to TRUE will not have any affect with regards background of objects underneath.
I need to be able to disable the keypad in a textfield, and instead when the user taps on it to start editing, a new table view will appear presenting a list of possible strings with which the textfield should be filled.
Anyone has any suggestions on how to achieve this?
Thanks in advance
p.s. I tried already but this functionality cannot be nicely implemented with a picker in my case, as there are too many options to choose from and (more importantly) each one of them is a rather long string and cannot appear entirely in a picker.
I believe you just need a regular cell that, when tapped, pushes a new detail UITableViewController with all the options to choose from. Once an option is chosen, set the cell's textLabel to whatever option have been selected.
If you'd like to go for an easier path, then you should also probably check the free Sensible TableView framework, as it has these kinds of cells out of the box (called selection cells). You just pass on your strings array to the selection cell and it will automatically display the detail view, and even assign the selected option to one of your object's properties if you wish. Should save you some good amount of manual work. Good luck!
I am using a UITableView to display some data which the user can filter. If a certain (perfectly "legal") combination is selected, all data is filtered out (hidden). I would like to display some text stating that no results were found and to please modify your filters.
Does anything trigger when this occurs that I can hook in to?
Or will I have to manually check for an empty data set and create a custom view to display my text? (I was thinking of creating a blank cell and using that footer? Hoping for something more elegant...)
I found a similar question, but the solution is not what I am looking for: Handling empty UITableView in UITableViewController
Also, I have an Android programming background and use this exact feature frequently, I would be surprised if Apple didn't do this as well!
Put a custom view with your error text message behind the table. Then when there is no data to be displayed set table.alpha=0.0 (or table.hidden=YES), while when you have this data available set table.alpha=1.0 (or table.hidden=NO).
You can do the control on the "OK" button (or equivalent) of the filter.