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.
Related
I got an application with an internal Role system. Based on the current role the user is able to see more settings. For each setting i got a ViewCell. So in my case i want to hide the special settings in the beginning and show them if the user has the right to do so.
Unfortunately ViewCell doesn't have a Opacity attribute, so i set my TableView to HasUnevenRows="true" and changed the size of the specific cells to Height="0". Now in code behind, if the User has the right to see the Cell, this is what i call:
PumpCell.Height = 42;
PumpCell.ForceUpdateSize();
This "unhides" the cell which is exactly what i want to do, but in the first place the Layout inside (I got an StackLayout nested inside an AbsoluteLayout) is hidden until the Cell is Tapped (see below)
Anyone has an idea to fix this? I even would be fine with manually invoking a Tap on the cell, but i haven't found a way yet to do so.
Thanks in advance
#Elias Johannes, I think you are using the listview, List view is having the issues while dealing with increase the cell size at runtime. Instead of Listview use the Repeater view.
Here is the link for sample,
https://forums.xamarin.com/discussion/87128/repeaterview
Prepare your datatemplate with the additional settings will be IsVisible=false at initial time and when the user clicks on it, take the current item instance and make it ISVisible=true through binding.
On iOS, when you append something to the beginning of UITableView's data source, the cell will "animate in" and push the rest of the cells down only if the user is already scrolled to the top. When the user is scrolled down farther down the list and a new item gets appended to the top, iOS does not automatically move the cells down.
When a new cell comes in from the top, how do I determine between the two?
My use case is that when the user has scrolled down past the iOS point, I can display a "new item above" button for the user to click . (similar to Twitter)
I'm using dynamic height for cells, so hard coding the scrollView by pixel isn't the most ideal way. I'd like to utilize iOS's way to determine it.
There is an array available of all visible cells' index paths called indexPathsForVisibleRows. You can access that property and check to see whether or not your first row is one of them, and go from there. You can also access visibleCells property to get the actual UITableViewCells themselves.
How to determine whether the user has scrolled past the first cell: a UITableView is a subclass of UIScrollView, so you can just look at the contentOffset property.
I'm not exactly sure that that's enough to accomplish what you want though. You could also maybe take advantage of the fact that tableView's cellForRowAtIndexPath: method only returns a cell if it's visible, and request the first cell. I've never tried implementing something like this before though so there might be a better approach.
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 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!
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