Closed JMattos closed 12 years ago
Also... sort of a similar question regarding StoryBoards and tabs. I dont see an easy way to control the instantiation of objects that act as the viewcontrollers in a set of tabs, so I'm not sure where I'd do the initWithDatasource.. how would I make FGallery occupy one of a set of tabs in the iOS5 world?
Hi John,
I haven't tried to work with FGallery yet in a storyboards scenario, so I'm afraid you're mostly alone on this one. What you may need to do since you cannot call initWithPhotoSource is subclass the initWithCoder method and perform the same view setup operations performed in initWithPhotoSource. My guess is that those initial view layers are not being created since that is not being called. If you get it working in a branch, I'd be happy to merge those change back into the project. Good luck.
Looks like I may be incorrect on adding the code from initWithPhotoSource into another subclassed method since it only assigns the datasource variable. Instead, you should look to see if initWithNibName... is called and all those setup operations perform properly with storyboards. I'd be curious to see what you find.
Hey there
I got it, I think. Your response really helped, I think I'd been looking at it too long. Essentially, when the FGalleryViewController comes out of the story board, initWithCoder instead of initWithNib, so I just did the following..
(id)initWithCoder:(NSCoder *)aDecoder{ self=[super initWithCoder:aDecoder]; if (self) { [self initWithNibName:nil bundle:nil]; } return self; }
I think I'd only do that if I had an actual reason for subclassing other than not changing the original code, which might be compelling enough, come to think of it.
if ([segue.identifier isEqualToString:@"ShowGallery"]) { FGalleryViewController controller = (FGalleryViewController ) segue.destinationViewController; controller.beginsInThumbnailView=YES; controller.photoSource=sender; }
Anyway, this turned into a bit of a rant ha ha ha, sorry about that. I think we've got it though. The only change I'd recommend is putting in initWithCoder so it'll work equally well with storyboards, and with nibs.
I'll look at the Tab version too to see if anything else is necessary, but I've got to go for a long run first. :)
One downside I see to subclassing FGalleryViewController is that _barItems is a private (well as private as it can be in OBJC) property, so unless I make barItems a real property, I'm losing access to it.
What I did is make a @property called barItems on the FGalleryViewController.h and synthesize it as normal in the .m, then override the setBarItems so that it does the same thing that "initWithPhotoSource:barItems:" does, specifically
-(void) setBarItems:(NSArray*)items{ [_barItems addObjectsFromArray:items]; }
Then, my prepareForSegue looks like this
if ([segue.identifier isEqualToString:@"ShowGallery"]) {
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(savePhoto)];
StoryBoardFGalleryViewController *controller = (StoryBoardFGalleryViewController *) segue.destinationViewController;
controller.barItems=[NSArray arrayWithObjects:saveButton, nil];
controller.photoSource=sender;
}
I can email you all this stuff if you like, too, if that will help you.
I didnt know how to fork the GIT Repo (I've never done that) but the changes are minor. I suppose that GitHub has some instructions on how to fork a repo?
Another slightly weird thing is that even if I dont change the _barItems. I'm not getting the left and right nav buttons automatically... do I need to create those manually? I dont see where they're being created in the FGallery "NetworkImages" page on the demo, but they're there...
J
Okay, forget the thing about the navigation buttons. I'm an idiot... I forgot to import the images. Duh. ha ha ha.
BTW man great work on this. I totally love it, and I'm absolutely going to use it :)
Alright, hell yeah. I got it working on a tab as well. Simple as can be.
The one thing I dont know how to do is keep the StoryBoardFGalleryViewController from taking over the full screen (and obscuring the tabs)... looking into that now.
I can zip up the project and email it to you if you like orI can post a zip to download.
Glad to hear you got it working. If you want to put it in your own repo or try to get a fork going I'd prefer to take a look at your source code that way. I'd have to post my personal email on here for you to send me files, and I don't really want to do that :)
In regards to your comments about the private _barItems property, I'll have to take another look at that and see if its a good idea to make it public. My initial thoughts is that it'd be a nice addition so you don't have to rely on the init methods to define those items. Thanks for the feedback, and glad you're enjoying using it.
Do you have any guidance on how to force the gallery to not take up the full screen for use with tabs? That's my only remaining problem :)
I'll try to figure out the whole forking thing, if now, I'll zip it up and put it on a public dropbox site you can grab. I agree about posting your email, I wasnt thinking.
@GladiatorApps I'm realy intresting by your code solution, can you me a link to download it please ?
For others with storyboards and segues:
This works for me
I'm trying to use segues and storyboards with the FGalleryViewController and i think I'm missing something
I have my TableViewController (which implements and the methods)connected to a View Controller which I've changed to the type FGalleryViewController in the Story Board, and in the
(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath{ [self performSegueWithIdentifier:@"ShowGallery" sender:self]; }
Then, in my prepareForSegue, I have the following
if ([segue.identifier isEqualToString:@"ShowGallery"]) { FGalleryViewController controller = (FGalleryViewController ) segue.destinationViewController; controller.photoSource=sender; }
The problem is there's no way to do the "initWithPhotosouce" so I'm setting the photosource after the fact.
Everything seems to work, except that the photos arent showing up.. just black. I'm using the default network images in the example and I debugged so I know they exist and are being set right.
am I missing something?