Switch from UIView to ScrollView in Swift - ios

Originally, the number of menus was one, but it was changed to more than one.
So I want to change the UIView (Container View) so that I can scroll horizontally.
Shop Menu View Cell is TableView -> TableViewCell -> TableViewCell (This) on the screen.
I tried several ways to switch to the horizontal scroll view.
I have separated the Container View and made it into a Cell
I also tried adding Scroll View or UICollectionView.
But all the way was not what I wanted.
Perhaps the Shop Menu View Cell is due to having passed the TableView twice.
I could not solve it for four days.
Please give me a hint how to implement.

To create editable forms of data display for static information, static TableViewController is best choice. As it automatically adjust your view when keyboard appear and other many feature, along with scroll. Plus you can directly outlet all the components to your controller class.
Your view will look something like:

Related

iOS UICollectionView switch cell NIB dynamically

I am updating my iOS app from table views to collection views to support a "gridded" option.
I have two cell types. One that is more suitable to a "tableView" type look, and takes up the full width of the screen. The other is a cell that is more suitable for grids.
I can't use the same cell type for both because the tableView type cell has a lot more horizontal information than the grid cell.
I have a button press event that will cycle between my cell types, updating the layout and changing the cell reuse identifier appropriately. The problem is, any cells that were already in view do not change to the new cell type. If I scroll for a bit, the new cell types start coming in.
I imagine that this has something to do with the dequeue function for collectionView taking an indexPath. I can explicitly reload those cells to get them to use the new type, but this causes an unwanted animation, not to mention feels like a hack.
How can I switch cell types dynamically?
Linked is a video demonstrating the issue.
https://imgur.com/1Q0Xu9S
As you can see, after I change the cells they remain using the old NIB (with all the extra information). But if I scroll down the new NIB will be used.
There are two solution for this: -
Use two collection view for each type of cell, hide and show respective collection view on click of button.
Remove the collection view from super view on click of button, add again and reload

One section of the view controller is still and one section horizontally scrollable

I would like to construct a view controller where one section of the view controller would be still and one section scrollable.
Both sections have headers where as well, one is still and one is moving along with the content in the section.
I do not want the cells in the section to be scrolled separately. All cells should move at the same time along with the header.
I have added an image to make my point little more clearer.
Use UICollection View for both view and disable scrolling for one view and enable scrolling for another view
you can probably add to your UIViewController view a UITableView on the left with fixed size (for example 150px) and vertical scroll disabled and a UICollectionView with horizontal flow and ,if needed a, with custom UICollectionViewLayout (but i think that you just need the classic UICollectionViewFlowLayout) for the right part that fits the remaining space.
Here you can find the component's documentation:
https://developer.apple.com/reference/uikit/uicollectionview
https://developer.apple.com/reference/uikit/uitableview

Two UIViews & one UICollectionView inside UIScrollView (or better approach)

I need to have iOS app with screen like this:
screen
The idea is when user start to scroll down the first UIView to move up until the second UIView reach the top where it will stick and only UICollectionView will continue to move up.
Currently I'm using this structure
UIScrollView (main scroll)
UIView (some banners)
UIView (UISegmentedControl)
UICollectionView (grid with items, scroll is disabled, main scroll is used)
I manage to do it, but I needed to set UICollectionView height constraint manually in the code (calculated based on all items in grid) in order to appear in UIScrollView (everything else is handled by AutoLayout in Storyboard). The problem with this is that UICollectionView think all cells are visible and load them, so the whole recycling & reusing thing does not work. It's even worst because I use willDisplayCell method on UICollectionView to load more data when last cell is displayed, but now it load all pages at once.
My question (actually they are 2)
How can I fix the issue above?
What is the right way to achieve this functionality? Maybe my whole approach is conceptually wrong?
Collection view is a scroll view itself. So maybe you could have same functionality only with Collection view with sections or even custom layout?

UICollectionView as subview of UIViewController

I want to use a collection view thats horizontally scrollable along the bottom 25% of my screen full of pictures and then use the top 75% of the screen to display information about the selected cell (zoomed in picture, caption, people in it, etc.) of the collection view. My question is how to go about implementing view controllers in this situation.
Will I need a UIViewController to handle the whole screen and UICollectionViewController to handle the collection view (how do I get them to work together?) Or could I implement the whole screen with just one view controller? (if so, which one?) Should I use a custom CollectionViewController with one section being my main info, and another section being the bottom scrollable part?
No, just have one UIViewController and add the UICollectionView as a subview. Then set the dataSource and delegate and tell it to reloadData. If it seems too easy, you're overthinking it.

How to make the dropDown in a UITableViewCell clickable without clickin the next cell and without adjusting the height of the cell?

I have DropDown class (the custom dropDown menu which is a tableViewController)
It is working (tested and used in other classes)
Then I have a PersonalInfo Class..
my PersonalInfo class is a TableViewController containing custom cells
Each cell has a UIView dropDownView and a textField contentTextField.
making the DropDown a subview of dropDownView, I'm able to make the dropDown menu appear on each cell. However, when the dropDown goes beyond the height of the cell, the dropDown items are not clickable anymore but they're still visible.
If i make the cell's height larger it works fine, but I want to keep the cell's height at a certain size.
I tried bringing views to front, never worked.
Can anybody help me? I'm running out of ideas..
thanks
With the drop-down being a subview to your cell, you can only control the content within that cell (I think...). From an "Apple Human Interface Design Guide" perspective, your approach is probably a bit unusual.
Firstly, you wouldn't really need every single cell to have a drop down, right? I mean, even if you have a drop-down menu within a cell, you'd only display one drop down at a time, and not multiple ones. So you could make the drop down a sub-view of the table. Or, more aligned with the standard approach, you would have a drill-down view that loads the drop-down / subtable into the current table, similar to all the tutorials on table views.
Hope this helps,
da_h-man

Resources