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 7 years ago.
Improve this question
I would like to know the efficient way to create an app in Swift. Will the number of files (ViewController files) in my Xcode project affect the performance of my app?
For example, for a simple arithmetic calculator app, in the first view I'll display 4 buttons for addition, subtraction, multiplication and division. If I click on a button, then it will open a new view to enter the data and process it.
So, now my question is, should I create 4 different viewControllers or should I use only one viewController to perform all the 4 operations?
Which one would be the efficient way?
First, your question isn't about Swift, it is about UIKit.
Second, you are looking at the problem the wrong way. Different view controllers will control different views. Switching from one view to another is a user action. Do you want the user to switch from one view to another, or do you want them to use one view all the time without switching?
If there is one view displaying different things, it's one view controller. If it's several views displaying different things, it's several view controllers. And I can assure you that the number of view controllers is not what makes your app fast or slow.
Related
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.
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
Hi there. Im new to ios, and i've been giving this assignment. I need to make a expandable/collapsable menu that can hold controls.
I have no idea on how to achieve this, and searching the internet has not proven fruitful - except for some navigation dropdown menus like this:
https://github.com/nmattisson/DropdownMenu
which is very nice, but ment for navigation, as i see it..
Any ideas? Thanks in advance
EDITED: Apparently the question was to broad.. I'll try to elaborate.
I need a menu i can place in certain viewcontrollers - each different viewcontroller can have different options, and often many different options. Therefore i need to add a menu that can be collapsed/expanded by a touch on the arrowbutton - as illustrated on pictures, and the collapsable menu must be able to contain different controls, depending on the context of where it is used.
After more research, i'm thinking a the usage of a container might be a part of the solution, and some animation to handle the expand/collapse.
So basicly - the menu could be something like the equivilant of an Android fragment, that can be inserted in the activities needed.
I hope this makes more sense.
You will try to play with Autolayout constraints ,
Ex : The height constraint of the container view is 60 in expanded mode ,if you want to collapse it change it to 0.
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 8 years ago.
Improve this question
I plan to develop an check list app that consists of multiple pages. Each page is going to display a list of simple Yes/No questions and a "Next" button at the bottom of the page.
In terms of the app design I see two options
One UIViewController with a stack of full page UIViews (layered, z-index). Switching from page 1 to 2 I'll use sendSubviewToBack
One UIViewController per page. Switching from page 1 to 2 I'll present the new ViewController.
Questions: What are are the PROS and CONS of these two approaches. Any other option that I've overseen? What are your experiences, suggestions?
Apple chose the one view controller per page approach in it's implementation of the same idea. That may be in part to maximize generality -- different users of UIPageViewController will obviously have different needs. But another consideration is memory; if you have a few dozen pages in the multiple subviews approach, you'll have a few dozen full-page subviews, and that's a quick way to use far more memory than you actually need at any given time.
If you do go with a single view controller and multiple subviews, consider instantiating the subviews only as you need them, and removing the ones that you don't need from the view hierarchy. Indeed, since it sounds like all your pages use the same format (checklist), it's hard to see why you'd ever need more than a single view for the pages. When the user selects a different page, you'd simply give the view a new set of data to draw.
Assuming you know how to write good code (reusing views / view controllers), they should have the same pros and same cons.
One pro in favour of the UIViewController approach is that it will most likely result in cleaner code. You also have the view lifecycle events like viewDidLoad, viewWillAppear, viewDidAppear, etc. which give you clearer view of what's happening.
I think it depends of what you are going to do on your views. If both have the same behavior with the datas, I would use just one UIViewController. If you have to make more and different treatments, I would use two UIViewController.
Using two also make easier a beautiful transition (handle by iOS) between them. If you use one, maybe you should use a UIScrollView and add the two views inside and scroll programmatically.
And another way to do that is to use a UITableView to show directly all the datas in one view.
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.
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.