I trying to make my app accessible, in my interface I have a UILabel and a UITableView, the tableView have a selectedRow. The selectedRow is the row in the middle of table view, for example is the row 50 if I have 100 row.
My problem is when I swype in screen to go to my next element, in this case when I go from label to tableView, the focus go to the first index and not to my cell was selected.
How I can fix that?
Assuming you have only a label and a table view, the problem boils down to keep in mind the latest position of the cell when you move from the label to the table view.
The following algorithm may be used to solve this problem :
Create a temporary index path variable (tmpIP) containing the index path of the selected cell.
When the label loses the focus, the table view selects the cell with the latest tmpIP index path. The variable value is nil if no cell was selected before the label selection.
Take a look at the UIAccessibilityFocus informal protocol to handle the focus of an accessible element.
Related
I have a setup a collection view with remembersLastFocusedIndexPath set to true.
CollectionView is designed such a way that it has nested collection views,
CollectionView
-> Section 1
--->Header
--->Cell nested with collectionview
-> Section 2
--->Header
--->Cell nested with collectionview
....so on....
There is pagination too.
Now if user scrolls to say 2nd item in 7th section and clicks menu in tv remote, I am scrolling collection to top. [either by setting content offset to 0 or scrolling to 0th index]
Requirement: After scrolling to 0th index, if user tries to focus on first cell in 0th section, I want focus to be at 0th index.
Issue: But now collection view remembers last focused index path and scrolls to 2nd item in 7th section.
Expected: I do not want collection view to remember the last focused index path in this case. In all other cases, it should be remembered. i.e, after scrolling to top, I want do something like
collectionView.scrollToTop()
resetFocus() //which should reset collection view's focus to initial index.
func resetFocus() {
//What should be written here to reset the focus of collection view.
}
try also implementing indexPathForPreferredFocusedView after you reset focus. Documentation here.
Given that:
For example in a collectionView there are 8 cells & each cell has a button & an image.Buttons here will display Yes/No Option to the user. Out of 8 cells only 1 cell will show "Yes" and remaining cells should show "No".
What i am looking is?
When i tap on a different button then current button show display "Yes" and previous button display "No".
I don't want to reload entire collectionView or cells inside a section in collectionView.
You can make use of reloadItemsAtIndexPaths method of collection View to reload multiple cells(In your case 2 cell i.e the minimum number of cells to be reloaded) instead of reloading whole collectionView.Pass the indexpath of the cell that you want to reload
ex:
//Logic to change button title Yes to No comes here.
collectionView.reloadItemsAtIndexPaths([indexPath1, indexPath2])
indexPath1, indexPath2 are the index paths to be reloaded.
i have a tableview with form fields, and there is a row that use segue to call an UICollectionView, everything is works except that i can't keep the selected cells (the visual effect that i show when the cell is selected) after go back to the tableview.
I mean, i selected my UICollectionView cells, after that i go back to the form, but if i need to again to my UICollectionView Cells, to deselect o select more cells before submit the data, once the UICollectionView appear my previous selection are there (i print the array, and i see the values) but i cant see the effect that i did for selected cells.
How i can keep the effect for selected cells if I'm going back to select again o deselect cells?
One thing to realize is that this is not going to happen by itself. When you segue back to the table view and the form fields, the UICollectionView is completely destroyed. The next time you show the collection view, it is a new and different collection view.
So, if you want to maintain a knowledge of what the selection was in the collection view, you are going to have to maintain it yourself, deliberately, storing it somewhere when you know that the collection view is being destroyed.
That way, the next time you show your collection view, even though that will be a completely new and different collection view, you can pass the knowledge of what the selection was to that collection view as you create and show it. The user will have the illusion of "returning" to the collection view, in the same state, but in fact you will have saved and restored its state.
It is then just a matter of reflecting the selected state in the collection view's display of its items. To do that, you need to configure your model so that when cellForItemAtIndexPath: is called, each cell looks selected if that item is supposed to be selected.
Every time you use segue to call an UICollectionView a new instance of UICollectionView is created and hence states of selected cells doesn't get restored.
I believe u must have taken an array of index paths of selected indexes to show the visual changes in the cell.
Make your tableView class as delegate of UICollectionView. Using its delegate methods return the selected index array to tableView class .And before pushing to UICollectionView send the same array of index paths back to the UICollectionView. Hope it helps.. Happy Coding.. :)
I am using a UICollectionView, in which one UICollectionViewCell covers the entire screen. Inside my UICollectionViewCell, I give people the opportunity to add text (UILabel), images (UIImageView) and color (UIColor). Now when the user navigates to the next cell i want the color, labels and image views to be displayed exactly as they were added on the previous cell. The users also have the option to pinch and pan the labels and images. In short, how can i pass on data from one cell to another?
I see several ways how to do this depending on your realization:
use global properties/ivars to store the selected data from user input.
In either case you probably handle UITextFiledDelegate methods in your controller or extract the cell by indexPath and copy values from the current cell to the next one.
And when the user presses the "Continue" button you:
1) If you create all you collectionViewCells at once in cellForItemAtIndexPath, then you should only reload the necessary cell via - (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths and set the values you have saved previously.
2) If you create cells but the next one is not ready (for instance you save the memory) - all almost the same - you add a new cell to the collectionView and read the data from your properties.
3) If you have not a "Continue" button or/and user can swipe the cell in every moment - so you can reload the cell in scrollViewDidScroll(or scrollViewWillBeginDragging) or extract the existent by indexPath and modify it without reloading.
In my TableView, the bottom cell has an "Add Cell" button that is used to..well, add cells. However, the app crashes if the user reorders the tableivew by moving a normal informational cell to the last position, making the "Add Cell": cell next to last.
I was able to prevent moving the "Add Cell" cell using tableView:canEditRowAtIndexPath:. I need something like tableView:canMoveRowAtIndexPath, but I only want to stop movement if they try to move it to the last position. Ideally, I'd need a hypothetical message like tableView:canMoveRowAtIndexPath:toIndexPath.
Any ideas?
I think you can do this by implementing tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: in your table view's delegate. Make the method return an index path that has a lower row number than your “Add Cell” row.