Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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.</p> <p>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:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import &lt;CoreData/CoreData.h&gt; #import "AlbumController.h" #import "SecondViewController.h" #import "FirstViewController.h" @class TabBarAppViewController; @class AlbumController; @class SecondViewController; @class FirstViewController; @interface Three20PhotoGalleryAppDelegate : NSObject &lt;UIApplicationDelegate&gt; { UIWindow *window; UITabBarController *tabBarController; AlbumController *albumController; FirstViewController *firstViewController; SecondViewController *secondViewController; @private NSManagedObjectContext *managedObjectContext_; NSManagedObjectModel *managedObjectModel_; NSPersistentStoreCoordinator *persistentStoreCoordinator_; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) UITabBarController *tabBarController; @property (nonatomic, retain) AlbumController *albumController; @property (nonatomic, retain) SecondViewController *secondViewController; @property (nonatomic, retain) FirstViewController *firstViewController; @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; @property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel; @property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator; - (NSURL *)applicationDocumentsDirectory; - (void)saveContext; @end </code></pre> <p>Please make sure that you create a new UITabBarController as well as all your ViewControllers. Let's continue with my Three20PhotoGalleryAppDelegate.m:</p> <pre><code>#import "Three20PhotoGalleryAppDelegate.h" #import "AlbumController.h" #import "SecondViewController.h" #import "FirstViewController.h" #import &lt;Three20/Three20.h&gt; @implementation Three20PhotoGalleryAppDelegate @synthesize window; @synthesize albumController; @synthesize firstViewController; @synthesize secondViewController; @synthesize tabBarController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // set up tab bar controller manually tabBarController = [[UITabBarController alloc] init]; albumController = [[AlbumController alloc] init]; firstViewController = [[FirstViewController alloc] init]; secondViewController = [[SecondViewController alloc] init]; /* This is the essential part of the solution. You have to add the albumController to a new navigation controller and init it as RootViewController*/ UINavigationController* navController = [[[UINavigationController alloc] initWithRootViewController:albumController] autorelease]; // now add all controllers to the tabBarController tabBarController.viewControllers = [NSArray arrayWithObjects:firstViewController, secondViewController, navController, nil]; [window addSubview:tabBarController.view]; [window makeKeyAndVisible]; } - (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)URL { TTOpenURL([URL absoluteString]); return YES; } - (void)dealloc { [tabBarController release]; [window release]; [super dealloc]; } @end </code></pre> <p>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:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import &lt;Three20/Three20.h&gt; @interface AlbumController : TTThumbsViewController { } @property (nonatomic, retain) NSMutableArray *images; @end </code></pre> <p>You can find the implementation of the AlbumController in the tutorial mentioned above. Now the AlbumController.m:</p> <pre><code>#import "AlbumController.h" #import "PhotoSource.h" #import "Photo.h" @implementation AlbumController @synthesize images; - (id)init { if (self = [super init]) { // Initialization code self.title = @"Photo Gallery"; self.hidesBottomBarWhenPushed=NO; } return self; } - (void)viewDidLoad { [self createPhotos]; // method to set up the photos array self.photoSource = [[PhotoSource alloc] initWithType:PhotoSourceNormal title:@"All in Vain" photos:images photos2:nil]; } -(void)createPhotos { // your independent implementation } @end </code></pre> <p>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 </p> <pre><code>self.hidesBottomBarWhenPushed=NO; </code></pre> <p>to your init() method like mentioned in the AlbumController-init-method above. </p> <p>Sooo, that's pretty much it. I really hope someone can re-use my solution. Thanks again to Bryan.</p> <p>Cheers guys, doonot</p> <p>PS: I have created a project on github. You can download the sample app <a href="https://github.com/doonot/TTThumbsViewController-in-a-TabBar-App" rel="nofollow">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload