Swift 2 Date Picker - ios

I have been messing around with date pickers for a university assignment and I came across something that is giving me trouble. Here is the layout of part of my project, which I will explain after the picture.
Basically, I have a date picker on my daily goals view controller. I want to be able to pick a date, then press the button "View Day", which will then direct me to the view controller on the right side of this picture. The view controller on the right will display goals for the day that was picked by the previous action. I can then add/delete goals for that specific day.
Now, I have looked at a few different ways of implementing this functionality. I would like to use core data to store arrays with indexes that point to specific days and goals for those days; however, I do not know how to implement this.
One idea would be for me to create an array of dates, which would point to arrays for specific dates. With these arrays for specific dates, there would be an array of goals for each specific day.
If anybody has any ideas on how to implement this functionality or any pieces of code or references that I could use, I would be very grateful!
Thank you!

Related

UITableviews inside UICollectionViewCells

I am trying to make a calendar like a google calendar in which each square has some text (events of the day).
For this, I think I must put a UITableView inside each UICollectionViewCell, but I am not accomplishing it. I don’t have a sample code because I don’t even know how to start solving this.
We don't need a UITableView, we can do it just by using UICollectionView.
But as you are new to this I suggest using a library JTAppleCalender.
With this library, you can create a calendar in iOS very easily and it is highly customizable.
List of features:
Range selection - select dates in a range. The design is entirely up
to you.
Boundary dates - limit the calendar date range
Week/month mode - show 1 row of weekdays. Or 2, 3 or 6
Custom cells - make your day-cells look however you want, with any
functionality you want
Custom calendar view - make your calendar look however you want, with
what ever functionality you want
First Day of week - pick anyday to be first day of the week
Horizontal or vertical mode
Ability to add month headers in varying sizes/styles of your liking
Ability to scroll to any month by simply using the date
Ability to design your calendar however you want. You want it, you
build it.
Github link: https://github.com/patchthecode/JTAppleCalendar
If you think that you don't want to use any library this answer may help you: Custom calender View

Using the same text field data for a calculation in different view controllers depending on options selected

I'm new to Swift and Xcode trying to find my way. I'm learning what I can through struggle, practice, and asking questions. Please excuse my novice level knowledge.
I'm developing an app in which the user will go through a series of questions, each on its own screen containing buttons with different options and sometimes a text field for them to enter a value.
My goal is to be able to use the text field data as variables for one calculation in a final view controller that displays a label with results for the user.
For example, on one view controller, there are two buttons to choose from... one is tapped if they want to know what they need on the final exam ("buttonFinalTakenYes") and another if they want to know what they need on the final before they take it ("buttonFinalTakenNo")...
then no matter what the choice, the next screen asks for their current grade in the class and they will enter a number into a text field and press next...
After a few more questions, depending on what they want to know, I want the final view controller to perform a calculation using all the numbers entered from the text fields leading up to it and display a result as a label. Basically, there are different equations that will display a result based on what the user wants to calculate, and each result will be on a different view controller using data from previous text fields.
I tried searching for answers but I can't seem to figure out what kind of code I need to use for this.
I know that I need to convert the String from the text fields into doubles so they can be used for calculations... but anything beyond that, I'm stuck.
I tried playing around with delegates and segues but it didn't work. Do I need if statements somewhere? Do I need to establish a new protocol? Also, would NSUserDefaults be relevant to this or is it just passing data between view controllers? What if the final view controller is many after the original text field?
Any guidance is appreciated. I feel like I'm making this harder than it needs to be.
Thank you so much!
👋 Glad to see that you are staying positive and asking questions instead of giving up.
I suggest you look up MVC (Model View Controller) because what you are missing in your code currently is the Model part. You need an object that holds all of the data the user entered throughout the app. Each view controller should add it's bit of data to this Model and then pass the model on to the next view controller in the chain.
By the time you are at the last view controller, you will have a Model object that contains all the data the user entered and you can do your calculations on that data and display the result in your last view controller's label.

Generate viewcontrollers for every day of the year

So the point is that I would like to have a viewcontroller for every day of the year in my custom navigation bar menu. I am using PagingMenuController library as my menu. There does not have to be 365 menu tabs, the interval can be like 90 days and every time the day changes it deletes the first day from the array and creates new one as last day of the array.
Basically is there a way to achieve it any way painlessly?
The app called ClutchPoints has this feature and I would like to get the exact same result.
This might be too much but I really hope there are some generous people out there who can help me.
Don't create 365 (or even 90) views at a time. You will have serious memory/performance problems if you do that.
You should look at the way table views, collection views, and UIPageViewControllers work. Those all only create the small number of views/view controllers that are actually visible at any one time, and configure the visible ones based on a data source that has the array of data that is being displayed. The views are recycled in order to manage memory.

Imitating split view animation used in iOS Calendar app

I am currently experimenting with a calendar framework I found online which possesses most of the functionality I need. However, I would really like to add a feature similar to the animation in the iOS Calendar where when a date is tapped, the view splits at that location and the selected week moves to the top of the calendar. Its an intuitive way to display info about the selected day. I just need some suggestions as to how this can be achieved since I'm not super familiar with collection views.
The calendar is a grid collection view with months as different sections from what I understand. Is it possible to just stick a supplementary view anywhere in a collection view dynamically? Or maybe I should look into adjusting insets at a specific location? I'm really not sure what direction to take and could use some suggestions.
Here is sort of what I want to do but with a table view.

how many cells to commence with in a UICollectionView for a Calendar? (i.e. with infinite number of dates)

How many cells to commence with in a UICollectionView for a Calendar? That is my understanding is:
UICollectionView is good in that it only instantiates cells it
needs to display, but then
You still have to add the cells to the collection view
So what is best practice if say your view would only show 10 cells, but you had unlimited cells (e.g. scrolling up and down dates in a calendar). Do you enter say 100 cells for 100 dates (say 50 either side of the starting date of interest) and then manually keep track of when you get to one of these edges and then add more? This would kind of be ashame the UICollectionView framework couldn't keep track of this itself no?
So overall questions therefore (sorry) are really:
How many cells (dates) should you be creating in the collectionview. Should it be limited therefore to say 100
Is there no support in UICollectionView to automate adding more cells in for you for a Calendar type situation where dates are endless if the user wants to keep scrolling forward or backward
Any what is impact on the caching strategy for UICollectionViewLayoutAttributes too?
There is a project on Github with a calendar based on UICollectionView
https://www.cocoacontrols.com/controls/rsdayflow
I have used this component in a production project.
You can easily change it's appearance since every day is a uicollectionviewcell.
This project is based on https://github.com/evadne/DayFlow
that can be a good base to create what you need.
If you want to build your own calendar it can help you to find response to your questions: the code is easy to understand, and the implementation is in my opinion quite neat
It depends on how much is visualized in one screen. If it is one month i would have one month before and one month later. If it is only a day, one day before, one day later. Then use this infinite scrolling trick. There are many examples outside. I didn't read through the following link, but the pictures visualize the idea nicely:
Building a Infinitely-Scrolling Gallery With a UICollectionView

Resources