I have a problem : I would like to implement a list of calendars (as in Calendar app of ipad) where the user can view a list of months along with their days. The user can pick a particular day and jump to another view ("day" view).
I am trying to do it by using UICollectionView and putting some kind of calendar (like CKCalendar) inside the UICollectionViewCell.
Beside the fact that there is some problem in handling events from calendars, there is also a problem about loading of the view which can take even half a second for let's say 9 cells.
Any advice?
Related
How can I achieve week view of the calendar in my iOS app as shown below, ideally using Apple calendar components (if any) and also how can I retrieve the selected date.
I have tried using both FSCalender and CVCalender plugins, without much success, as each was missing one element or the other.
The answer is, you lay out a bunch of views and set their contents. Perhaps use a collection view for the horizontal days. Definitely use a table view for the times. There's nothing in the public SDK to do it all for you. You just put together a view hierarchy the normal way.
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.
Pre-requisites - Environment: iOS 9.0 or above - using Swift 3.0.1
Thanks for your responses. I'm updating the question and trying to give a better understanding about the problem.
Posting code would help may be but I'm not allowed to post the code as I do not have the IP.
But I am trying to build something like calendar/program guide where you have events for each category for several days.
Imagine, categories on your left side in a column and they can be the sections of the collectionveiw and each category has events for several days which is a row.
CAT 1 : Event 1, Event 2 ... Event n
CAT 2 : Event 1, Event 2 ... Event n
CAT 3 : Event 1, Event 2 ... Event n
.
.
.
CAT m : Event 1, Event 2 ... Event n
Problem: The entire data is pretty dynamic and humongous. I can't prefetch all the records, they are about over 80-100K. It takes few minutes to download all the data and display it on the grid.
A user could select any day and any time and I have to scroll the collection view to that day and time and display those events for the categories. Also, user could obviously scroll in both directions to and browse the events in this case the events are loaded like infinite scroll fashion.
In the former option though, when the user jumps on to a particular day and time on the entire timeline and I have to skip loading the other previous events (as I do not have them yet - unknown) and display the events relevant to the user selected days and time.
I do not have all the IndexPaths in advance, to display on the screen, how can I skip events and dynamically update the collection view in parts like we load images dynamically and the ones which get loaded first and displayed earlier than others.
I'm using startDate of the events to calculate the xPosition, categories don't change often after they are loaded so we could somehow avoid reloading sections but items in those sections change all the time and they appear in a random fashion.
When the controller loads the first set of events are fetched from the server and displayed, now if the user decided to jump to some D-Day and T-Time which could be anywhere on the entire timeline I have to fetch the events for those dates and populate the items for relevant sections (visible on screen) and update the interface. This is where I have issues, where I do not have an proper approach.
Hope this is clearer.
I have "tried" to mock this up
UICollectionViewFlowLayout can help you achieve what you want...
https://developer.apple.com/reference/uikit/uicollectionviewflowlayout
https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/UsingtheFlowLayout/UsingtheFlowLayout.html
You have the same problem I had with my calendar project. The solution I have implemented will not work for you, but I am mentioning it here so that it might give you clues on how to solve it for your situation.
My calendar has a function where a user can scroll to some date way into the future. The problem was that date cells can be custom sizes. Therefore, since they are scrolling to some future date, in order for me to know the destination offset, I needed to know the offsets of cells 0 -to- destinationOffset because the cell sizes are different. This meant I had to query the sizes of all the cells in the middle which led to a 2-3 lag time (or in your case, a long download time).
So here was my solution.
I originally had a delegate function called sizeForCellsAtMonth which was called for every month in order to determine the size. I have now changed this function to be called only once.
The function now only has two parameters:
defaultSizeOfCells
exceptionToDefaults - this will be specific months where the cell sizes are different
Using this information, I can calculate the sizes of all months because I know the sizes before hand. So my problem was solved by changing the way I looked at my delegate. Maybe you can try looking somewhere along those lines or maybe my answer gave you clues of what you can do.
For my application I have to develop a view that displays the events of a calendar in a Week View, just like the landscape view of the iPhone calendar app.
I was thinking about using a CollectionView but I don't know if is possible to have the content of the cell continuing in another cell, in the case of an event covering multiple hours, like this example, in which the description can continue trough multiple cells:
Is there any plugin I can use to create this view?
I'm working on a couple of iOS apps that require the user to select a calendar date, and while the built-in date picker widget is all right, I'd much prefer if users could choose days from a calendar grid, similar to how it works in Hipmunk's iOS app. In that app, users are shown an infinite scroll view showing a grid of days, with each cell showing the month and day. The days of the week are shown in a persistent (i.e. non-scrolling) banner.
In addition to simply showing a calendar, this control should allow dates to be highlighted/selected. Better still, users should be able to select a whole range of dates by tapping on the start and end days' cells, at which the whole range of days should be highlighted.
Any ideas?
It's an "infinite" UIScrollView with various other views inside of it. Apple provides a demo infinite UIScrollview in their StreetScroller project.
You'll be allocating and initializing views for the various things you wanted displayed on each day, and probably reusing views at the top for the dates (as one scrolls off to the left you change the date and move it over to the right, reusing it the way a UITableView traditionally does).
Selection is a matter of changing visible state of the objects that back your views.