Differences between view controllers [closed] - ios

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Hi I'm new to Xcode and don't quite understand the difference between all the view controllers. Eg what is the difference between a uiviewcontroller with a collection view on it and a uicollectionview controller it self? Confused as to why I wouldn't use a view controller then add views onto it depending on my requirements eh table, collection etc. Can anyone help to shed some light?

It's based on your requirements. You may change some properties with your View controllers. But when you use as part of its' controllers, you can't change it.
For example you Can´t change UICollectionView Size of UICollectionViewController(see this).
In these case, you must use UICollectionView in viewcontroller. As like this, if you want to customize some property but functionality are same in all.
Here I mention some ref for you: Ref

You can take UICollectionViewController as a template which will have every thing for you. And view controller is simple scracth pad, you have to add things on it. There are some pros and cons in view controller you have to do every thing yourself, but collectioViewController you got controller with collectionView. But you can not change things as easily in it.

Related

Custom page controll with words instead of dots - Swift [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am currently making a timetable in a collectionView.
I want the user to scroll through the weeks using paging in the collectionView.
I am struggling to change the dots into words like: Monday, Tuesday, Wednesday. IS this possible using page controll, or should I code from scratch? See image for example
You can try this pods, I think it will help you.
https://github.com/rechsteiner/Parchment
Parchment is a very flexible paging view controller. It let’s you page between view controllers while showing any type of generic indicator that scrolls along with the content. Here are some benefits of using Parchment:
https://github.com/xmartlabs/XLPagerTabStrip
XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers. Pan gesture can be used to move on to next or previous view controller. It shows a interactive indicator of the current, previous, next child view controllers.
I think you can make it custom components. It's easy to implement.
Take UICollectionView to this paging options. And add UITableView below to UICollectionView.
Change your data after select any item in UICollectionView.

How to let a user duplicate a view [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've a countdown app, it counts the time towards and since a date that the user chooses, and would like to know how to allow a user to pick more than one countdowns.
I'm thinking if there is a way to let the user duplicate the view, but I could be far from right, I'm new to this.
Any help would be much appreciated.
Thanks.
Given the requirements that you mention on your question and the follow up comments, I think perhaps the best is to use a horizontally scrolling collection view, with each cell taking up the whole screen.
(before the advent of autolayout, I would have recommended a UISCrollView with the content size varying at runtime as you add pages, but setting up UISCrollView correctly with autolayout is a steep learning curve. UICollectionView and UITableView take care of this for you behind the scenes).
The setup would be like this:
In the storyboard, embed your view controller in a navigation controller, so you can (perhaps) have your "Add Countdown" button as the navigation bar's right bar button item.
Next (still in the storyboard), add a collection view to your view controller and wire any outlets/delegates/etc.
Implement your data source so that it reflects how many countdown objects you currently have, and set up the "add" button so that when tapped, it creates a new counter and refreshes the collection view.

Tricky transition in custom view [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Good day everyone!
A customer asked me to implement a view. Here you can download and look at video how this view should work. (Left cells are days, right - hours)
It's kind of calendar view.
I've tried to do this task with collection view and custom layout. But do not hit much success. Because of the tricky transition of left cells. They become smaller (to speed up scroll), but right side is still the same.
Is there any possibilities to create such transition in collection view or picker view? Or should i use base view with overriding draw method?
Regards, Eugene.
It's a calendar, so it's essentially infinite, so I don't think a UICollectionView or UITableView is appropriate for this (e.g. what would you return as the number of cells?).
I'd be creating custom UIView subclasses for the left and right side, and overriding drawRect.

Many tutorials describe methods for adding multiple child view controllers in the Storyboard, why don't they just add multiple container views? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Many tutorials, such as this one go over how to add multiple child view controllers via the Storyboard. But this tutorial just adds multiple container views in the Storyboard.
Why is the first tutorial (and many others) going through such hoops to create multiple child view controllers if they could just use multiple view containers? Is this a new feature, or am I just misunderstanding what's going on?
As the other poster said, container views and embed segues were added in iOS 6. In iOS 5 adding child view controllers was more work since these options were not available.
Container views and embed segues only work with storyboards. Some developers don't like and don't use storyboards. In that case you would have to set up your child view controllers yourself.
I think container views and embed segues are wonderful, and make setting things up much easier. By all means use them. They do most/all of the housekeeping for you.

Is it better to embed a view controller or add a subview? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
For example, if I required a UITableView to appear beneath additional content in a view, would it be best practice to either:
add a UITableView as a subview, or
add a container view holding a UITableViewController?
As far as I know, both would provide the same user experience, however I am interested to know which method would be considered best practice?
You have several options:
Add a UITableView and make the containing view controller the table view's data source and delegate.
Add a UITableView and make some other class the table view's data source and delegate.
Create a separate view controller with the table and then add the 2nd view controller as a child view controller of 1st.
The choice depends on the appropriate division of responsibility and encapsulation.
Options 2 & 3 allow for reuse if you ever need to embed the table view in more than one view controller.
There is no simple answer to your question. It all depends on your needs, your data, and your app's structure.
The general rule for iOS, especially for the iPhone/iPod touch form factor, is that you should have only one view controller on the screen at any given time. The only case I can think of when you would want to violate that guideline is when you have a subview that has a lot of logic built in to it, and the subview needs to be included in multiple other views. For example, a popover should have its own view controller because it might need to be shown in conjunction with multiple other view controllers.
In your case, I would strongly suggest just adding the UITableView as a subview unless (1) the table view has a lot of logic that isn’t related to that of the parent view controller, or (2) you will need to display the same table view in another part of your app.
I would rather use a container view controller for the following reasons:
It can be reused in another part of the application.
Maintains single-responsibility of the objects (Main view controller focuses on displaying information about the model, and the table view controller handles displaying information about a relationship in the model, for example).
Keeps source files smaller and easier to read.
Easier to build tests for.
Ultimately though, they are both valid solutions.

Resources