ViewCell.ForceUpdateSize() layout inside appears only after Tap in Xamarin.Forms - ios

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.

Related

How can I get IndexPath of currently selected tableviewcell by voice over?

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.

change order of list in tableview by clicking on whole cell

I currently have a 'tableview' with a list of items and I have enabled an 'edit' button to go into edit mode which shows the 'reordering controls' on the right side of the screen. I have also enabled 'canMoveRowAtIndexPath' and 'moveRowAtIndexPath:toIndexPath' to allow for the user to hold and drag the reorder control on the right side to reorder the list and have the data model update.
Is there a way to enable this but allow the user to click and drag the whole cell and not only the 'reorder controller'? Essentially I want to enlarge the area of the reorder controller's function to the whole cell when tableview is in editing mode.
for anyone else who is interested, I used this guide to get it working: b2cloud
the starting code template does not work as optimally since it has nib files and I'm using Xcode5 but it still works. The important code is all in the actualy tutorial as he lists how to set the reorder control to the size of the size via inserting it as a subview.
There is a way to enable this that allow the user to click and drag the whole cell and not only the 'reorder controller'!
Please check it out: https://github.com/FlorianMielke/FMMoveTableView
This might be helpful to you, Sir :)

iOS: Make content (text) in table view cell editable, but only in edit mode

I know this has been asked a lot of times but theres so much different information and different cases, I just don't understand where to begin and cannot get it working in my app.
In my app I have a table view and I'm using a NSFetchedResultsController. In normal mode, the table cells shouldn't be editable but instead each click should be a segue to a new viewcontroller (which works). In edit mode however I want that if you click on the cell, that you edit the text and this gets automatically stored to the database. And here I don't have a clue.
I want it as simple as possible. What I've read so far I guess I have to subclass UITableViewCell and a TextField. Here's already my first question: In each post about this, the TextField is init with a Rect, however how do I know the exact width and height of my cells?
And do I add this cell directly in the cellForRowAtIndexPath? Or only if the mode gets changed to edit? And some posts suggest you have to be the delegate for UITextField, but why?
And is there some sample code for about exact the problem I have? I wasn't able to find it...

how to connect textfield with table view of listed options instead of keypad

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!

Table View Design Issue

My app design required a page that display 'user information' and i currently have this setup using a simple table view in a View controller. Now, the tricky thing is I need to be able to provide functionality to the user to be able to edit these on the same same screen. So essentially when the user taps on a row in the table view, I want that little flashing text line at the end of the current text in the row so the user can edit what's currently present and I also want a save button to apear on the top when a user has started editing. The tricky part is, not all fields in my table view will be editable. So, I need certain fields to be editable and have the save button appear and certain fields not.
Can you tell me how would I go about modifying my existing design to implement this functionality? I would appreciate some code if you think you can show me how exactly I would go about doing things.
You would probably want to make some custom UITableViewCells. You can fill a tableview with all sorts of different cells which are different sizes and looks different, all at the same time. I would suggest a custom UITableViewCell which will hold a UITextField as one of the subviews. On the cells which you don't want user interaction with the textfield, either make a new custom cell that uses a UILabel or just do textfield.userInteractionEnabled = NO. Look up some custom uitableviewCell tutorials to get you started and then use the approach that I suggested for your problem.

Resources