All. I am new to Swift. I am trying to create something similar to the image attached below. My question is regarding the table view.
I create a prototype cell for each recipe, in which contains an image View and a textfield. However, how should I arrange those cells like those in the picture attached?
It seems that each cell has a different height. I thought about including multiple recipes in one prototype cell, yet it may not be the right solution.
In the real world, how do people handle such arrangements? Maybe people use something other than prototype cell?
Your help is greatly appreciated. Thanks in advance.
You can achieve this thing by using collectionview. If you know width and hight in advance then you can simply create collectionview with constant width and height of cell. if you don't know the dimensions in advance you need to do some extra task in collectionview which is selfsizingcell.
This is called 'waterfall collection view', you can find similar thing in Pinterest app. Size of each cell is dynamically calculated based on the width&height of picture itself.
Personally I've used this open-source github project, in order to implement same thing in my app.
Related
I was wondering if there is a UICollectionView implementation around for displaying views (images) in a grid as shown below.
I started to build it with UITableView, but it is getting really complicated if an item doesn't fit in the same row with its predecessor/successor.
I came across this the other day, which is similar to what you want to do and may work out:
http://pierceboggan.com/post/56951869926/pinterest-style-uicollectionviews-in-xamarin-ios
It is a modification of a UICollectionView made to work like the waterfall layout that Pinterest uses.
The default UICollectionViewFlowLayout, in horizontal mode, can do a lot of what you need, but it can't do the yellow cells, spanning multiple rows.
You could subclass the flow layout, and modify the layout attributes for each cell to have the correct position and size.
I'm trying to implement a scrollview where the cells auto zoom as they near a certain point in. As a cell nears the point it will start enlarging and as it moves away - it will shrink. I've been trying to find some tutorials around this but haven't had much luck. Any help would be greatly appreciated.
UICollectionView with a custom layout seems like the right way to do this. A UICollectionViewLayout gets to define the layout attributes for each item, including size and position. All you need to do is define a layout that positions the cells in a grid or however you like, but adjusts the size of the cells according to their distance from the point of interest.
You might find some sample code associated with the collection view talks from WWDC 2012 -- there were some interesting layouts shown there.
I am not the most experienced iOS developer and so far only had some simple designs I worked with, but now we plan to build views based on tiles, which I have no idea how to approach, yet. I tried searching for solutions, but haven’t really found something which could help.
This is what we plan:
Row 1 (fix): Tile 1 (fix) | Tile 2 (fix)
Row 2 (scrollable): Tile 3 | Tile 4 | Tile 5 | Tile 6
(unfortunately I am not allowed to post a picture)
Two tiles per row should always be on the screen.
Each tile should contain its own layout and controls, in fact a MVC for each tile. The top two tiles should stay fixed on the screen, the second row contains four tiles that should be horizontally scrollable.
Could someone point me to the right MVC-architecture I should be using here? Are there maybe iOS controls which already support this.
Any hint on how to begin and how to design it is highly appreciated. Or a link to a tutorial.
I came across the UICollectionView, but I am not sure this is the right approach. I am planning to do that for iOS6, so I can also use the latest available controls/classes.
Thanks a lot for your help!!
Nek
Make a view and a view controller. Add to this view a subview for the fixed tiles. Add to the rest of the screen a UICollectionView as a subview to the view. Assign data source and delegate to the UICollectionView and write the delegate and data source methods. You are done.
You can use the UIScrollView class. In UIScrollView you can make it scrollable as you want.
For your requirement you can use UIScrollView as each row.
Im trying to implement a nice accordion effect on my app. My goal is to "open up" a cell when the user tap on it, diplaying additionnal content (such as text) as the cell height increase.
The perfect sample code for that is the TableView Animations & Gestures sample code provided by Apple. However I am experiencing a strange behavior, that ruins the whole effect.
It appears that depending on the order in which the tableview will display its cells (top --> Bottom or Bottom-->up) the cells textviews will overlap each other or not.
As its a bit difficult to explain with word so here is it with images.
Those screenshots were taken from the TVAnimationsGestures Sample Code, without any changes made to it. It comes from the first version of the sample code without storyboard:
Now the version with the storyboard, first behaved well, but after a while, and without me touching the code it started drawing this :
And I have the exact problem on my custom with my custom cells.
It took me a while to understand what I think the problem comes from. If cells are drawn from the Top cell to the bottom, there is no such problem. However if cells are drawn bottom to the top, they will stack in reverse and therefore overlap each other. I don't think it is possible to control this behavior.
What gave me the hint, is that when I scroll down, forcing the top cell to redraw, they actually redraw nicely, and the screen looks like this:
A Mixture of overlapping cells and "good" cells.
Again, this all comes directly from Apple sample code, without any changes.
Does anyone knows whats going on?
Thanks a lot for your help.
You can increase the cell height by pinching on the cell.
I have an array of scores in my iphone game. All I want is a plain list, just text of these scores.
Do I need to load this into a UITableView then somehow remove the background of the table, so it appears as just text, or is there a different method I can use to get this list as just text?
Thanks.
I think you need to better define what "as a list" means to you. You could construct a multiline string containing those values and disposing in a UILabel or UITextField but I can't tell if that would make sense for your data and your desired UI.
How many scores do you have? Will they all fit on the screen at one? Do you need to be able to scroll the list? Do you want to be able to tap on the scores? Copy them? Format them differently?
You certainly could also create a table view with a tranparent background on the table and it's cells. Just be aware that transparent cells are more expensive to render and will not scroll as smoothly as opaque cells.