iOS Dynamic Views inside a view controller - ios

In our project we've a requirement like this.
Our webservice sends the neccesary data to create views in our applications
These datas are consist of multiple views with an order.
For example it can send a data like this
[{"ViewType":"Table","datas:":[....]},
{"ViewType":"PieChart","datas":[...]},
{"ViewType":"BarChart","datas":[...]}]
So we are going to show all these views in the same view controller , and when the user first open the view he/she will see the table then he'll scroll down and see the piechart etc...
Is something like that possible with any kind of design pattern in iOS
If it is how?
Thanks

You can use the table view or collection view. Each cell can have the single view, on the basis of count of the views, you can set the number of cells of the tableview or collection view. Disable the horizontal scrolling if required.

Related

reusable view in iOS

I need to display different data at the different instance in a page with respect a list selection on the same page. Is there any mechanism like fragment is in ios. how to solve this. I need to display a list of horizontal items at the bottom and with respect, the selection the content on the page should be changed​.
You can use Collection view and in cell of collection-view , you can create pages with scrollview. Also you can create manage collection-view as horizontal/vertical.

UISearchController: single vs separate tableview for display and search

I need to have a search bar for a table view that displays a list of data, not sure whether I should use one table view for both displaying and searching, or have separate table views for display and search respectively.
Single table view:
+ feels easier to implement by just switching data source
- extra work if I want to maintain the scroll position (after searching) of the display table view
Separate table views:
+ no extra work needed to preserve scroll offset of the display table view
- extra work to switch between display and search modes
Is there anything critial I missed? What is the recommended way?
Update:
I need the search bar to stick on top, so it can't be the tableHeaderView of the table view (which scrolls when table view scrolls), or section header view because I've got different sections.
Thanks!
I've used a single table view and used a read only property to filter the array of items based on the search text.
I stored the original data in Property X and based on the text entered in the search bar i filtered the data returning by the Property (readonly) Y and used as the table data source.
Using the search bar delegate method you can then filter the contents of the table as the user enters text into the search bar.
The first one is the recommended way to implement the searching functionality. Managing the datasource is easier then to handle the two different tableviews.
You can try for UISearchController which provides the searchBar with a TableView and can have delegate methods to handle the case.
Here and here are some good tutorials to do the same.

How to create a complex scrolling view in iOS similar to yelp?

Yelp has this View show up when you click on a specific restaurant or some event:
In the picture above there is the Cascal label, then Write a Review button, then three buttons (Photo or Video, Check in, Bookmark) all in a row, then a map, and some cells underneath (Directions, Call, Explore the menu, etc.).
How can you make a complex scrolling view similar to this (do you have to use a collection view or table view?)? Since in both a tableview and collectionview you are reusing the same cells again and again (with the same layout) so it is difficult to create a view with so many heterogeneous elements like in the picture above.
Use a table view and a bunch of different cell classes each with their unique design (XIB or Storyboard) and height.
Select the cell class and height depending on index path and let table view delegate methods return accordingly.
Very basic stuff actually.
You only reuse cell classes if you need to. In the Yelp example the Directions, Call, Explore the Menu and More Info cells may have used the same design because the layout seems to be identical, only the image and text differs.

Nested collection view in table view is better or multiple collection view

I have to showcase some image with a little information like title and subtitle which will be horizontally swipeable. Basically, it will be like Airbnb app which shows the category and elements in it with horizontal swipe. The only difference is that in my case number of category(row) is fixed, which is 2. DataSource is same for both rows. I have two approach first is using two CollectionView and second one is by using a TableView and nesting the CollectionView inside tableview cell. Googled and get only the implementation part for both approach not the comparison or use cases for the approach. So my question here is, which process should I follow and why?
1) Using nested Collection view will make the code complex.Generally used only when cannot be implementable using table view.
2) Table view is similar to collection view just that it can be scrollable vertical not horizontal. This make table view easy to implement.
3) In your case collection in table view will work great. Row is fixed in that case you can use static table view.

drill down UITableView using storyboard in iOS program

I'm trying to develop an iOS app that has drill down UITable View. I got a drill down table view tutorial, but the number of UITableViews is static. What I need is a dynamic one. My requirement is simple. I need to access an FTP Server and get the directory hierarchy (I guess I need to store it in NSDictionary or in an xml file) and display the content in the UITableView. If it is a text file, I need to display it in some view, otherwise I need to display the selected folder's content in the same UITableView, and it goes on till the bottom of the directory hierarchy.
I need to use the storyboard.
I've had to make a something very similar to what your talking about in a previous application I worked on.
In that I created table views inside of table view cells with a button at the top to expand and collapse the view using the cell height.
This worked pretty well but since then I've found the best way to simply programmatically add ui elements to either your table view cells or view.
In both cases I created a management system using parent child architecture to hold your information.
I hope this puts you in the right direction :)

Resources