I have quite a complex setup, and am looking for advice in how to structure my code. What I'm trying to do is something similar to twitter when you press one of a users images and can swipe through them. This is what I have at the moment:
- A
UIViewController
subclass that gathers data from a server, and passes it to aUITableViewController
subclass through a variable calledtheData
- This
UITableViewController
subclass also gathers more data as the users scrolls to the bottom of the table view and appends it totheData
(i.e. uses pagination). ThisUITableViewController
subclass is reused throughout the app so that data from a different source can be passed to it. - When a user clicks on a
UITableViewCell
, aUIWindow
is created which has aUIPageViewController
inside it. The window uses theUITableViewController
as a delegate to accesstheData
, and passes thetheData
from the delegate to theUIPageViewController
in a variable calledpageData
- Each page of the
UIPageViewController
is aUIViewController
that loads images from thepageData
The next stage is to do pagination as the user swipes to the end of the pageData
in the UIPageViewController
. However I don't think my code is structured well enough to reuse the pagination code from the UITableViewController
. Please could someone give me advice on how to improve this code structure?
Thank you
EDIT
The UIViewController
in the first bullet point does more than just downloading data (it has other views within it).
I use a UIWindow
to encapsulate the UIPageViewController
because I want it to expand from the frame of the UITableViewCell
and "take over" the full screen - covering the status bar.