Casey
unread,Feb 24, 2012, 7:15:51 PM2/24/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Three20
I'm extending the TTThumbsViewController class for my own photo
gallery and I'm having a really hard time figuring out the best way to
initialize the gallery. On viewDidLoad I initialize my custom photo
source just like the rest of the examples:
- (void)viewDidLoad
{
[super viewDidLoad];
PhotoSet *photoSet = [[PhotoSet alloc] init];
photoSet.title = @"Gallery";
self.photoSource = photoSet;
[self loadData];
}
That last line is my call to get the JSON list of images that need to
be shown. Since I'm using RestKit for all of my data needs I do not
use the - (void)load:(TTURLRequestCachePolicy)cachePolicy more:
(BOOL)more method. My JSON call then returns a list of URLs that will
be used to initialize the TTPhoto objects. The problem is that since
my view controller has already been initialized and pushed to the user
before the JSON request is made.... by the time the JSON request
returns the screen only shows the "No Photos to Display" message.
My question is, what is the best way to reinitialize the
TTThumbsViewController after it as already been pushed to the user?
After a few hours I came up with what seems like a very hackish way to
show the photos. Here's what I have so far:
- (void) loadGalleryImagesComplete
{
//...initialize photo objects
((PhotoSet*)self.photoSource).photos = photos;
if([photos count] > 0)
{
[self showEmpty:NO];
[self showLoading:NO];
} else
{
[self showEmpty:NO];
}
[self showModel:YES];
[self didShowModel:YES];
}
As you can see, I have to manually manipulate the loading and empty
messages. While all of this does work, there has to be a better and
more proper way to initialize the TTThumbsViewController once it has
already been pushed to the user. Like I said, I tried a few hours of
trying invalidateModel, invalidateView, reload, loadView,
modelDidFinishLoad, etc.... and this is the only thing that worked.
Does anyone have a suggestion for a cleaner implementation?