我参考了这篇教程,为iPhone创建了一个照片库。现在我想将其添加到我的TabBar项目中。我已经听说Three20不支持XIB,所以我改变了整个选项卡栏的设置方式,采用程序化方法。我认为我离最终解决方案并不远。
我能够在一个选项卡中使照片库正常工作,但是没有功能(点击图片 - >它会打开等)。页面上没有导航栏,无法进入详细图片页面。我遇到了这个问题,当我从应用程序委托的didFinishLaunchingWithOptions方法中删除了它时。
感谢大家,谢谢,dooonot
我能够在一个选项卡中使照片库正常工作,但是没有功能(点击图片 - >它会打开等)。页面上没有导航栏,无法进入详细图片页面。我遇到了这个问题,当我从应用程序委托的didFinishLaunchingWithOptions方法中删除了它时。
// 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