How to achieve a (almost) full view uitableview that can scroll past the last cell and show further elements in iOS - ios

I have attached the below image because it describes my problem better than words:
So basically, I need the Title/Subtitles part at the top to always be static, after that a dynamic UITableView which will have a lot of cells (mostly will fill the rest of the screen), and then after that a few additional elements such as a Map View and etc.
I'm using storyboards/xibs for this so it was also an issue of how to constraint everything in the designer properly. Would a stack or scroll view be appropriate for this?

I think you can take two paths to achieve this.
The first is to create a custom cell containing the map and another containing the "Paragraph of text" thing.
Then you only need to push the cells at the end of the original data source.
Keep in mind that you need to add this cells to the RowsInSection function.
The other way is add a custom footer view to the tableView.
You can create a custom UIView containing the map an other info and then tell the table to take the custom view as footer:
tableView.tableFooterView = customView

Related

Can we add tableview to cell?

I want to customize my tableview. I want to add another tableview in cell. Can we add tableview in cell of another tableview?
Please give me some ideas.
You can embed a UITableView into another UITableView's cell, but due to potential issues with the embedded UIScrollViews it is not recommended.
If you feel like you need a table in a table, first consider if it is not possible to achieve the desired behavior by using sections and cells in the sections (a section in a table might represent the top tableView's cell, and cells in the given section would represent the embedded tableView's cells).
There is no problem with adding a UITableView into a a UITableViewCell, since both of them are UIViews its simply would be translated to adding a subview to a view...
However, keep in mind to consider the following issues:
1- From a user experience perspective, that would be a vertical scroll view inside another vertical scroll view (are you ok with that?).
2- For each cell -in the main container table view-, you would need to handle the table view delegates/datasources. For understanding the logic of how this could be done, you might want to check:
Is it possible to add UITableView within a UITableViewCell.
Putting a UICollectionView in a UITableViewCell in Swift: although it is about adding a UICollectionView inside the cell, it helps to gain the logic of how to achieve such a task.

How can I place a view between cells in collectionView?

I want to place a view between cells in a collectionView. Like an ad. to be added dynamically after they see the first 3 cells. Is there a method to do that?
If you could figure out a way to do that you still shouldn't. A collection view owns the area it draws in. It's in charge of placing cells where they belong within it's content view, and you are supposed to keep out.
That said, collection views are extremely flexible and you could design your collection view to display a set of "normal" cells, an ad cell, and then more normal cells. If your ad cells are different sizes or need to be spaced differently than your normal cells then you might have to create a custom collection view layout.
No, you can't. But you can add a UICollectionViewCell which will contain advertisements or something else you want to be added. It is really simple. Just create two prototype cell. First cell will contain your data, second one will contain some extra data.

How to make cell doesn't scroll along with other cell?

I am making an app that use table View Controller and static cell.
I want to make first cell don't scrolling while other can. This is a picture of what i am talking about.(Sorry for my bad English)
For example as in this picture, I want to make 9gag tab stay when scroll. If you play instragram you will see that when you scrolling the name of user will stay until you scroll into another one. However I want it to stay not changing when it encounter second cell.
Any suggestion?
Using UITableViewController would not help here. You can use these steps to get what you want:
1. Create a UIViewController.
2. Add UITableView as its subview.
3. Add another UIView as UIViewController's view's subview.
4. Using auto layout constraints, you can put UIView above UITableView
This way, you will get a sticky view at the top.
Ok, not exactly sure what you're after but i'll take a stab.
Firstly, if you want the section to remain in place until a new section of items is present, you just need have a look at sections. This is an automatic feature. You may not see it occur until you have plenty of items in the sections.
UITableView With Multiple Sections
There's plenty of stuff about it & not too hard to implement.
My other guess of what you want:
If you want it to remain static regardless of anything, perhaps you could just create a view and place it above the table view. why does it need to be a part of it if it doesn't change?

Is it possible to merge the cells in a UITableView so that i can add some image at the right side?

As seen in the image of my design that i have attached, i want to merge(don't know wether thats the correct word) the first three cells so that i can display an image at the right side in the table itself. Is it possible?
No it's not possible. Instead, you can create first three as one cell(type1), other cells are other type(type2).
Update: see this tutorial for how to create custom cell.
You can create a UIView with fixed dimensions(say, 200x200) having 3 textfields (number, name & uom) to left and add UIImageView to right. Create IBOutlet of this view and name it. Add this view to the header of your UITableview.
self._table.tableHeaderView = yourview;
You should use a UICollectionView instead and apply a custom layout to achieve this.
Collection views provide the same general function as table views
except that a collection view is able to support more than just
single-column layouts. Collection views support customizable layouts
that can be used to implement multi-column grids, tiled layouts,
circular layouts, and many more. You can even change the layout of a
collection view dynamically if you want.
There are many tutorials on the Internet:
http://skeuo.com/uicollectionview-custom-layout-tutorial
http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12
Another option is to use UITableView and a custom UITableViewCell.
Example:
http://www.idev101.com/code/User_Interface/UITableView/customizing.html
add it in the first cell.The size of you imageview shoud be greater than the cell height.Make sure cell.cliptobounds is set false.Make sure you set the zpositon of imageview to 1 by imageView.layer.zPosiziton = 1.
Actually, you can add your imageView as subview of tableView, so your didSelectRowAtIndexPath: will working as usual

UIcollectionview decoration view VS supplementary view

I'm starting my development of an ios app using ios 6 and UICollectionView.
I've noticed there's support for both supplementary views and decoration views.
Can someone please explain in bullet points the difference between the two? They sound very similar.
If I want to add a loader to my collection view (that will appear at the bottom of each section, while the section is loading) should it be a supplementary view or a decoration view?
Thanks
Decoration views are just what the name says: decoration, chrome. Only the collection view layout decides what they are and where to put them (for instance, if you want to draw lines on the screen every 5 items).
Supplementary views are more related to your data. The collection view layout still decides where to put them, but they are provided by the collection view data source, just like regular cells. For instance, if you wanted to put titles for sections, you would use supplementary views because the title would be different for each section and you need to call the data source for each.
If your loader is generic, it could be a decoration view, however decorations views are not really accessible (the layout object says where to put them, and that is it, they are created by the collection view and you never get a reference to them), so if you want to start/stop animating it, a decoration view is not the best choice. If you use a supplementary view, then you have access to it at creation time (in your data source collectionView:viewForSupplementaryElementOfKind:atIndexPath: method). However, you can only query the collection view for regular data cells once they are laid out on screen.
Also, you will have to write your own UICollectionViewLayout class if you want to use custom decoration or supplementary views. The base UICollectionViewFlowLayout only provides for a footer and a header supplementary view.
from UITableView perspective :
Supplementary = sections.
Decoration = tableFooterView tableHeaderView

Resources