UITableViewCell next to eachother - ios

How can i make a tableview where the cells are next to each other. Where there are 2 on each row. example like this? In the second row there are 2 images next to each other. Can this be done in a tableview by making custom tablevieCells?

Yes this can be done in UItableViewCell But preferred to use collection view for this kind of view.
Just subclass uitableviewcell, add new method
-(void)setCellWithNumberOfImages:(NSInteger)images withImage1:(UIimage *)image1 withImage2:(UIImage *)image2;
if(image2 ==nil)
//add only one UIimageView with image1
else
//add two imageviews.

You need to use a UICollectionViewController (https://developer.apple.com/library/ios/documentation/uikit/reference/UICollectionViewController_clas/Reference/Reference.html)
Using a UICollectionView you can implement a custom layout which layouts the elements as in your screenshot

You can Use UICOllectionView That's much easier and customizable, you can chose how many item you want to have in a row and size for example.
for more information please check: UICollectionView Class Reference

Related

How to add a subview to a TableViewCell?

I need to add a subview to TableViewCell when the button in TableViewCell is clicked it should show another tableview as a subview and height of the tableview should be dynamic according to number of cell.
How can I do this?
Above screenshot is taken from a very popular shopping app and I need to do the same in my project.
You can easily achieve this using simple UITableView. For that you need to set all your main categories as your UITableview section and respected sub-categories can be added to respective rowOfSection.
You can use just one table view with UITableViewStyleGrouped style, and set "Men","Women","Kids & Baby" as TableView sections header, keep an boolean value to determine the result of "numberOfRowsInSection:" of each section and reload tableview.
See the below link at github:
https://github.com/OliverLetterer/SLExpandableTableView
This contains the Expandable TableView, which you required. You have to implement SLExpandableTableViewDelegate and SLExpandableTableViewDatasource which contains different method, in which you have to provide inner tableview as well.
Hope this helps you.
You need to do some work on your own I can give the directions that'll give you a way from my point of view :-
Make a Custom cell which you want to expand.
While designing the cell make its height in storyboard like 200 or so according to your need and add all the elements those you want to see when the cell is expanded.
You'll need two delegate methods first -didSelectItemAtIndexPath and second HeightForRowAtIndexPath at index path.
First You need to make sure the user taps on the button or cell that you want to expand , and to achieve that you need to call didSelectItemAtIndexPath.
Once you get your cell Position, in HeightForRowAtIndexPath check the indexpath is equal to your cell's indexpath,if yes then return the exact height(ie:200) of your cell otherwise return the default(ie:70) height of you cell.
Note : In didSelectItemAtIndexPath you need to call to method to update the current cell
[self.tableView beginUpdates];
[self.tableView endUpdates];

Swift custom cells layout TableView decision

I need to display a table with in my iPhone app:
neither the number of cells nor the contents are known at compile time, but only at run time.
Views for each cell may differ, one cell has textField and another may have some other view control.
Should I consider Static or prototype cells?
Should I consider tableViewController or viewController with tableview in it?
Any thing I need to consider before I start coding? Thanks in advance
For The issue of dynamic Number of cell at Run time, you can call reload data for table view at any time you have the data source ready.
Prototype Cells should be used with no problem.
Simple Table View will be sufficient for the task.
You have to make cell, either in code or in storyboard, for each type of cell you want, 1 table View can have multiple types of prototype cells, Just name them differently and then make the objects of only the specific cell of which the data is best suited.
It is not that difficult but do handle the data source with extreme care.
Should I consider Static or prototype cells?
If you know all possible subview combinations that your cells might need to display the data appropriately, and they are relatively few, make one prototype for each. for example:
One text field,
Two labels,
One image view and a label,
...etc.
Otherwise, just use the plain-vanilla UITableViewCell (no subclassing) and remove/add subviews at runtime when reusing them (that is, inside the method -tableView:cellForRowAtIndexPath:).
Should I consider tableViewController or viewController with tableview
in it?
The only reason I would choose UIViewController + UITableView over UITableViewController is if -for example- I needed the table view to only take up part of the main view's bounds/screen, and display some other subview in the remainder. Otherwise, you get so much "for free" with UITableViewController that there's just no point in implementing all of that from scratch.
You have to choose prototype cell, u can create different types of cell depending upon your requirement.Any think ok for u, u can create tableview controller or view controller.

Placing an UImageView inside ? or outside ? a UITableView

I'm trying to display an image with a tableView like so (see image below).
But I'm not sure about the way to implement the red part :
is the red part in the header part of the table view ?
is the red part outside of the table view ?
is this in a custom cell ?
PS : Note that the tableView I would like to be with the picture would have various sections.
Thank you very much for the help.
In this case it's either a header or a custom UITableViewCell because it scrolls with the table. You can implement it either way.
Personally I'd start by making it a cell. That will allow you to use autolayout to easily tackle sizing and dynamic type.
create a custom view as per suthar's comment and add it to the tableview headerview ,
if you have more than one sections than u can use the groupped tableview instead of plain tableview...it becomes more easy..

How to create 'containers' similar to Facebook?

I'm creating an app that will get data from an RSS feed and I want to know how I recreate something similar to the Facebook app 'containers'
An example of what I mean is below.
How would I go about recreating the boxes where the statuses are held?
To achieve your desire result you have to create custom table view cell using UITableViewCell and arrange views as per your need by creating subclass of UITableViewCell
Just create a UITableView with different prototype cells and then deque the appropriate cell identifier in cellForRowAtIndexPath.
You probably have to subclass UITableView for achieving the desired effects such as indentation etc.
After that you have to make custom view for each cell and return them from the method cellForRowAtIndexPath

Add more than one SearchBar in tableView

It's possible to add two searchBar's in one View controller. For example, I have a static table view with two rows, in each row I want to have UITableViewCell with searchBar. I can't find any way how can I do this in the Net. It's possible?
The answer is YES. You can place as many UISearchBars as you want. Create a custom UITableViewCell and place a UISearchBar inside of it.

Resources