How to make an effect of expandable UICollectionView cell in iOS - ios

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!

Related

How to place UILabel exactly below UITableView?

I have UITableView with height of ≤500. Tableview data comes from database. Below UITableView, there is one label and two radio button. The problem is if data in the UITableView is less than its height, then it shows blank space between UITableView and those two radio button. I want to place those label and radio button exactly below tableview. How should I do this ?
This is how my tableview looks
If the table view's height does indeed vary depending on shown content, you could use UITableView's tableFooterView.
For a bit more context see this post for example.
Alternatively you could do this with basic auto-layout by tying your label and radio buttons (that you place as siblings of the table) vertically to the bottom of the table view.
I could also imagine that you may need a section footer. So you may want to have a look at that too.
If you want it to be scrollable, add it as the last row in your table view. You may also go with table view's footer.
If you want it to be sticky at the bottom in case of more rows, go with auto layouts. You may create outlet of table view's height constraint and adjust that accordingly depending on the number of rows. However, this approach is not appreciated.

Put UITextView underneath undefined number of UITableViewCell's?

I will have a number of cells (typically 5-6), and I want a text view underneath it. But I want the position of the text view to change based on the y-value of the lowest cell.
That way, no matter how many cells, the text view will be directly under the cells.
I tried placing the textview within the tableview, but it hid the cells.
Not sure what else to do.
you could for example set it as the tableFooterView...
(see https://developer.apple.com/reference/uikit/uitableview/1614976-tablefooterview)

Best approach to achieve this grid layout on iOS

A question for the UICollectionView experts.
Imagine a collection view that looks like a table view (full width cells), and when you tap on one of them, new cells are inserted underneath that cell that are square cells, say half the width of the collection view, in 2 columns. Tapping the header again would appear to collapse the section.
Keeping in mind that I’m trying to use UICollectionViewFlowLayout instead of a custom UICollectionView.
Would you:
A) implement the tableview style cells as collection view supplementary views (headers), with a gesture recogniser that inserts the square cells?; or
B) implement the tableview style cells as one cell type, and the square cells as another cell type?; or
C) something else?
Personally I would go with option A. In the situation you're describing the full width item is really a section header that's function is to show/hide it's sections's cells.
From a data structure standpoint this is much easier to maintain with this approach. It can be handled with an array of arrays.
If they were all cells it would most likely be one large array, and would be more difficult to make the distinction between a full width cell and the half width cells.

position custom cell in a tableview not fully showing a cell

Okay What i want to do is position a custom cell so that the cell looks like only a portion of it is shown in the UITableView. When you swipe it to the left it goes to a new viewcontroller that allows the user to add details for a new cell. My question is how do we position the UITableViewCell to show only a portion of it in the tableView?
What i want to do is position a custom cell so that the row is not shown fully like about 1/4th or 1/2 its actual length only in the table view
here is an app with the functionality i'm trying to implement this is the image url as i can't post images yet
http://a3.mzstatic.com/us/r30/Purple6/v4/01/16/ec/0116ec99-0206-d125-7d27-d5956b918635/screen568x568.jpeg
I want to implement my cells just like how they implemented their expenses in cells, the cell is positioned according to the amount in it ,if the amount is high the cell is placed further to the left else only 1/4th of the cell is shown(empty cell no expense )
Can we achieve this by making an imageview in a customcell and then changing the x-axis of the image view according to the amount entered in the cell? Thanks in advance
For this, I would do it this way :
For each of my model cell I add a state, in the delegate of UItableView i use heightForRowAtIndex to set the size depends of the cell's state.
To not show extra view (when the cell is cliped) use :
[myCellview setClipToBounds:YES];
I think it should do the tricks. Even if it's not the best way to do it!
Solved it i Just had to add a scroll view to the cell's content view and then add a view containing the color to the scroll view. So its coding is similar to the swipe deletion in 'UITablView'
https://github.com/TeehanLax/UITableViewCell-Swipe-for-Options
this repository helped me out, i only had to make a few changes otherwise that was it thanks for all your suggestions :)

Number of Cell prototypes exceeds tableview height

I have a tableview that has a large number of fairly tall dynamic cells. I've tried creating the prototypes for these but I've run out of height room in the view.
I can't seem to extend the height of the table view, (or the view it's in). I also can't create the tableview outside the viewController, give it a larger height, and just link to it.
Suggestions? I know I can create the cells programmatically or from a separate nib, but I'd really like to do it via storyboard.
thanks,
Just figured this out myself. Try this:
Double-click the table almost anywhere except where there's an existing control. You can also double-click on the outer edge of the table.
Note that the table view will show a highlighted section that aligns with the cell you've clicked. You've entered some sort of selection mode.
Now use the mouse to scroll up or down. The cells will shift up or down as if you were running the app.

Resources