我完成了本教程并为 iPhone 创建了一个照片库。现在我想将它添加到我的 TabBar 项目中。我已经听说 Three20 不支持 XIB,所以我将整个标签栏设置更改为编程方式。我认为我离最终解决方案不远了。
我能够让照片库在一个选项卡中工作,但没有功能(点击图片->它打开等)。页面顶部没有导航可引导您进入详细图片页面。当我从应用程序委托中的 didFinishLaunchingWithOptions-method 中删除它时,我遇到了这个问题:
// 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;
我不得不将其删除,否则不会显示整个标签栏。照片库使用整个屏幕。我不确定它是否只是未显示或未加载。我也试过:
tabbar.hidesBottomBarWhenPushed = NO;
但这根本不起作用。我试图将 TTNavigator 代码添加到 AlbumController 本身的 loadView()、viewDidLoad() 和 init() 中,但没有结果。有谁知道我必须把它放在哪里才能让它工作?
我的 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
我对 didFinishLaunchingWithOptions 方法的实现:
- (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;
}
谢谢大家,干杯,dooonot