Animate tableView for future/past months - ios

I have a project that uses a simple UITableView to represent a month of items. Each row is a day of the month and the table represents a single month. There is a small view at the top of the table view with buttons to move forward in time (Next) and backwards in time (Prev), one month per click. This all works perfectly fine.
What I am searching for is a way to "slide" the current month off and the next/previous month on when the appropriate buttons are clicked. The affect would be similar to using a page view, but there could be "infinite" (indeterminate) number of months forward/backward, so this seems to eliminate using segues, page views, etc.
I have found code to animate the left/right movement of the current tableview, but these don't seem to fit the bill either: I need a "new" table view to move into view as the "old" table view moves off.
The only thing that seems to make sense is:
Create a new table view "offscreen" and populate it
Animate the current table view to move off screen as the new table view is animated moving on screen
Swap "old" and "new" to prepare for the next transition
Seems like a ton of work, which I guess is OK but I'd hate to invest the time if there is a better way. Any ideas?
Thanks!

Related

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.

Create a listing inside of a ScrollView

I am writing a Swift app, and on my main screen I have a long scrollview with several regions of content in it (upcoming events, announcements, and then featured products, and finally some basic info). So it's this really long scroll, and you can swipe down to the bottom.
So visualize 4 boxes, if you will, stacked vertically.
The 3rd box shows featured products. This can be anywhere from 1 to 30 items, depending upon any filters the user has in their settings.
My first try was using a UITableView for region#3 inside of this parent scrollview, but the problem is it only shows the first few items/rows and then the rest you scroll inside the table (which is the default/natural behavior of a table, right?). Unfortunately, the requirement I have is that the inner table can't scroll - it needs to display everything at once and you have to scroll (in the main UIScrollView) to get to the bottom (not scroll inside the inner uitableview scroll). Also, everyone seems to say don't use UITableView inside of a scroll.
So how do I create some sort of list where I create one template (like how you would in a xib/tablecell, and then assign a data source to it, and then repeat down without scrolling? Should I use a tableview after all, and just make the height of it very high and turn scrolling off?
Do I somehow instantiate xibs in a for loop and assign them dynamically to some view?
Thanks so much!
Sounds like you want a Table View with Grouped style. That would make it fairly easy to keep your "4 boxes" segregated, and your "3rd box" would simply be 1 to 30 rows in that section.
On note: you don't want to have a "very tall" table view - or any other type of view, for that matter. You want to allow iOS to manage memory for you, and to load and display only those parts of your content that is visible at any one time.
In other words, use a table view like its designed to be used :)

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.

Calendar like horizontal scrolling menu

Does anyone know a library I could use to make a slider menu like in the image below?
slider menu
Like the image, I need to display the days of the week
What I've tried:
(1) Using CAPSPageMenu repo on github but I came to realize this is inefficient for what I need. I only need one view controller, and will have hundreds of menu items (each menu item is a day of the week)
Other possibilities:
(1) Should I create a tableView, rotate it 90 degrees, and allow that to function as the horizontal scrollable menu?
(2) I found a tutorial online that lets me embed a collection view inside a tableView cell... But it seems rather cumbersome to make a cell for every day of the week.
That would be pretty easy to create using a UICollectionView. Do NOT try to rotate a table view. That path leads to madness.
You could use the shortWeekdaySymbols from NSCalendar to get the names of the days of the week.
Create a UIScrollView and put calendar date views inside it.

ios - Making UIScrollView scroll smoothly

In my iPad application, i've a scroll view that lists images of 20 video albums. The list of 20 images will be sent by server.
Now when the user reaches end of scroll view, i've to send a request to get next 10 videos details.
After fetching the data, i want to add them to the scroll view at the end. But I want to delete the 10 videos at the beginning. So that at a time scroll view will show only 20 video details all the time.
When user scrolls again to the end, i'll send request to server, get next 10 video details and add them to the scroll view, remove 10 beginning video details from scroll view...... and similarly when user scrolls to the beginning i'll fetch 10 previous videos and repeat the same.
Here i want to make sure the scrolling must be smooth and don't want to have flickers in scroll view. can some one suggest to have better scroll view coding to achieve my requirements please?
If your code contains scroll.pagingEnabled = YES; Then please remove this part of code.
It will surely work.
The real problem here will be in setting up cell recycling. It's not that hard to do, I have a couple examples of which you can look at, one being here. You'll need to make some changes to that code of course, it is set up in "pages" — Only one view on screen at any one time, and I don't think that's what you want.
Aside from that...
Your critical part here will be in designing your data source in a way that allows removing of old items, and adding new items, without skipping items.
For instance, the way I might approach this is to render the "last" item in your scroll view, the same as you want the first item in the scrollview to be. When the user gets to the last item, set your content offset to the start of the scrollview without animation (haven't actually tried this, so there may be a jolt that you don't want, test it and see). This will give the appearance of endless scrolling. Your data source would simply overwrite old indexes when adding new items, instead of adding to the end of an array for instance.
If you are presenting then in the form of a grid view, I suggest you take a look at AQGridView. That grid view supports cell queueing and dequeueing, which does exactly what you describe.
You can also use the delegate method scrollViewDidScroll: to determine if you're at the bottom of the scrollview and trigger the download of the next set of albums.

Resources