How to programmatically scroll ScrollViewReader component inside UITableViewCell
Basically, I have 2 horizontal axis (rows) inside UITableViewCell.
As shown in an attached gif file, I select the h3 option on the first axis, explicitly scroll, and move it out of bounds.
On the 2nd when I selected option v4, the first row selected option also should be visible on the screen.
When the user selects open on the axis(row) it shows selected in center position by below lines of code.
.onChange(of: viewModel.selectedId) { _ in
proxy.scrollTo(viewModel.selectedId, anchor: .center)
}
I want to apply the same things to previously selected row. so I this case, auto-scroll to the selected option in the first row when the user performs q selection action in a second row.
Does anyone know how can I do it?
Related
I haave to implement 3 seperate forms, but they have headers which make the forms collapsible when clicked.
When searching online I saw the expanding rows for UITableView. Is it possible to add a custom form view in the expanded view of the tableView? Or do I try another approach with 3 hidden views that appear when each of the header sections are selected?
I always use UIStackView inside my cell. And when user click expand button, i unhide views and call tablewview.reloadData(). This is my approach
You can use 3 stack views. Each stack view will have a heading label and a tableview inside it. By default all the tableviews are hidden and heading label are not hidden. Add a tap gesture to heading labels. Whenever user taps a heading label you can unhide the respective tableview. You can give tags to each heading label and tableview so you can identify which heading label is tapped, like if a user tapped heading label with tag 1, you will unhide the tableview with tag 1.
I have list of 5 button in each row for UITableViewCell
Total number of row count is 2.
If I select the first button in first row or second row then the other button of the same position should be deselect in another row vise versa
Please find the attachment:
1 way:set relationships between your buttons and their owner cell. Reload layoutsubviews of cell to set its buttons' image.
2 way:set Tag for each button and reset corresponding button image in one button's action target.
I have a collection view 3x3.
Item (collection cell) contains some icon and label.
I want some additional text to be shown inplace when user touches the cell. The view with this text must be fullscreen width.
In other words I want to insert a view with text between collection rows. It's desirable that the view appears with animation.
How should I do that? The first ideas I've got are:
Divide CollectionView rows into sections and use section footer for this purpose. Make this footer of zero size and show it when needed.
Dynamically create full-width cell and insert it at the end of the row where selected item is located.
Both methods seems tricky to me. Maybe there is more straight forward way?
Any ideas? Thanks!
So each row has the same button and I want that button to scroll to the next row.
In tableView, you can set each button has different tags(button.tag). When you selected it, use tag to decide which row you will scroll to.
I want to do something similar to the left UITableView on imdb app on ipad.
Once you have selected an item, it will become the first item on the top and it will dock there. When you flick the list below, it will always be there.
Anyone has any suggestion on how I can achieve that?
That's not part of that UITableView.
It is a seperate UITableView with a custom UITableViewCell that is actually the same as in the UITableView with all the information about the selected film or character ...
When no film is selected, that second UITableView isn't visible. But as soon as you select an item, that UITableView at the top will become visible with the information about the selected item. That means that you will have to reduce the height of the UITableView (with the detail info about that item) so that the UITableView at the top will get some space for being displayed. Everytime you change the item, you need to update the UITableView using the general delegation and datasource methods for a table view. Once there's nothing selected, you just set the upper table view to hidden, and set the other table view's height to the full height.
That's all.