I wend through this tutorial and created a photo gallery for the iPhone. Now I want to add it to my TabBar project. I already heard, that Three20 doesn't support XIB, so I changed my whole tab bar setup to programmatically. I think I am not too far from a final solution.
I was able to get the photo gallery working in one tab but without functions (click on a pic --> it opens, etc). There is no navigation on top of the page that leads you to the detail image page. I faced this when I removed this from didFinishLaunchingWithOptions-method in app delegate:
// Override point for customization after application launch
TTNavigator* navigator = [TTNavigator navigator];
TTURLMap* map = navigator.URLMap;
[map from:@"demo://album" toViewController: [AlbumController class]];
[navigator openURLAction:[TTURLAction actionWithURLPath:@"demo://album"]];
return YES;
I had to remove it because otherwise the whole tab bar is not shown. The photo gallery uses the whole screen. I am not sure if it is just not shown, or not loaded. I also tried:
tabbar.hidesBottomBarWhenPushed = NO;
But that did not work at all. I tried to add the TTNavigator-code to loadView(), viewDidLoad() and init() in the AlbumController itself without a result. Does anyone know where I have to put this in order to get it working?
My AlbumController.h:
#import <Foundation/Foundation.h>
#import <Three20/Three20.h>
@interface AlbumController : TTThumbsViewController {
// images
NSMutableArray *images;
// parser
NSXMLParser * rssParser;
NSMutableArray * stories;
NSMutableDictionary * item;
NSString * currentElement;
NSMutableString * currentImage;
NSMutableString * currentCaption;
}
@property (nonatomic, retain) NSMutableArray *images;
@end
And my implementation of the didFinishLaunchingWithOptions-method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// set up tab bar controller
tabBarController = [[UITabBarController alloc] init];
albumController = [[AlbumController alloc] init];
firstViewController = [[FirstViewController alloc] init];
secondViewController = [[SecondViewController alloc] init];
firstViewController.delegateRef = self;
tabBarController.viewControllers = [NSArray arrayWithObjects:firstViewController, secondViewController, albumController, nil];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
// Override point for customization after application launch
TTNavigator* navigator = [TTNavigator navigator];
TTURLMap* map = navigator.URLMap;
[map from:@"demo://album" toViewController: [AlbumController class]];
[navigator openURLAction:[TTURLAction actionWithURLPath:@"demo://album"]];
return YES;
}
Thanks guys, Cheers, dooonot
Ok guys, with help of Bryan I was able to get the photo gallery running in a tab bar application. I have seen so many people out there looking for this solution so I try to explain it as good as I can.
Seems like it is not possible to use Three20 with Interface Builder, so you have to set up your tab bar application manually. This is my Three20PhotoGalleryAppDelegate.h:
Please make sure that you create a new UITabBarController as well as all your ViewControllers. Let's continue with my Three20PhotoGalleryAppDelegate.m:
Please note that you don't need the TTNavigator stuff from the tutorial. Now we have to get our photogallery some how. I built it up in AlbumController like in the tutorial. This is my AlbumController.h:
You can find the implementation of the AlbumController in the tutorial mentioned above. Now the AlbumController.m:
As described in the problem description above, my photo gallery always used the full screen. This is bad because you cannot use your tab bar icons anymore. For this you have to add
to your init() method like mentioned in the AlbumController-init-method above.
Sooo, that's pretty much it. I really hope someone can re-use my solution. Thanks again to Bryan.
Cheers guys, doonot
PS: I have created a project on github. You can download the sample app here.
Try This:
You can use the TTNavigatorDemo sample to learn how to use it with Tab Bar Controllers.