2011-07-16 21 views
0

美好的一天,我想問問你們中的任何一個人是否可能遇到過像我這樣的問題。我一直在使用Three20框架的TTNavigator開展一個項目。每個視圖都會按照它的顯示和過渡。我有一個應用程序菜單,它具有應用程序各個模塊的按鈕。問題是,當我點擊按鈕到特定的模塊,並顯示該視圖時,TTNavigator的URL屬性值是應用程序菜單視圖(tt:// mainMenu)的值,而不是模塊的初始視圖(例如「tt:// messageBoard」或「tt:// profilePage」)。我已檢查並檢查了可能與此問題相關的必要代碼塊,但我似乎無法處理手頭的錯誤。TTNavigator網址值與當前VC不匹配

下面是我的AppDelegate

#import "Three20TestAppDelegate.h" 
#import "StartViewController.h" 
#import "JumpsiteProfilePage.h" 
#import "MenuViewController.h" 
#import "BNDefaultStylesheet.h" 
#import "MessageBoardViewController.h" 
#import "GroupListViewController.h" 
#import "DrillDownGroupListView.h" 
#import "ProfileListViewController.h" 
#import "ProfileDetailsViewController.h" 

#define UIColorFromRGB(rgbValue) [UIColor \ 
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ 
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 

@implementation UINavigationBar (UINavigationBarCategory) 
-(void)drawRect:(CGRect)rect{ 

UIImage *image = [UIImage imageNamed:@"NavBar BG.png"]; 
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; 

self.tintColor = UIColorFromRGB(0xFFD900); 

} 
@end 

@implementation UIToolbar (UIToolbarCategory) 
-(void)drawRect:(CGRect)rect{ 

UIImage *image = [UIImage imageNamed:@"NavBar BG.png"]; 
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; 

self.tintColor = UIColorFromRGB(0xFFD900); 
[super drawRect:rect]; 
} 



@end 


@implementation Three20TestAppDelegate 


@synthesize window=_window; 

@synthesize managedObjectContext=__managedObjectContext; 

@synthesize managedObjectModel=__managedObjectModel; 

@synthesize persistentStoreCoordinator=__persistentStoreCoordinator; 

- (void)applicationDidFinishLaunching:(UIApplication *)application {  

TTNavigator *navigator = [TTNavigator navigator]; 
navigator.window = _window; 
navigator.persistenceMode = TTNavigatorPersistenceModeAll; 
navigator.supportsShakeToReload = YES; 

[TTStyleSheet setGlobalStyleSheet:[[[BNDefaultStylesheet alloc] init] autorelease]]; 

TTURLMap *map = navigator.URLMap; 

//startView(Log-in View) 
[map from:@"tt://startView" 
toSharedViewController:[StartViewController class]]; 

//Application's Menu 
[map from:@"tt://mainMenu" 
toSharedViewController:[MenuViewController class]]; 

//User's Profile module 
[map from:@"tt://profilePage" 
toSharedViewController:[JumpsiteProfilePage class]]; 

//Message Board module 
[map from:@"tt://messageBoard" 
toSharedViewController:[MessageBoardViewController class]]; 
[map from:@"tt://groupList" 
toSharedViewController:[GroupListViewController class]]; 
[map from:@"tt://drillDownListView" 
toSharedViewController:[DrillDownGroupListView class]]; 

//Profile List module 
[map from:@"tt://profileList" 
toViewController:[ProfileListViewController class]]; 
[map from:@"tt://profileDetailsList" 
toSharedViewController:[ProfileDetailsViewController class]]; 

[navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://startView"]]; 

// Override point for customization after application launch 
[_window makeKeyAndVisible]; 
} 

- (void)applicationWillResignActive:(UIApplication *)application 
{ 
} 

- (void)applicationDidEnterBackground:(UIApplication *)application 
{ 
} 

- (void)applicationWillEnterForeground:(UIApplication *)application 
{ 
} 

- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
} 

- (void)applicationWillTerminate:(UIApplication *)application 
{ 
[self saveContext]; 
} 

- (void)dealloc 
{ 
[_window release]; 
[__managedObjectContext release]; 
[__managedObjectModel release]; 
[__persistentStoreCoordinator release]; 
[super dealloc]; 
} 

- (void)awakeFromNib 
{ 
} 

- (void)saveContext 
{ 
NSError *error = nil; 
NSManagedObjectContext *managedObjectContext = self.managedObjectContext; 
if (managedObjectContext != nil) 
{ 
    if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) 
    { 
     NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 
     abort(); 
    } 
} 
} 

#pragma mark - Core Data stack 

- (NSManagedObjectContext *)managedObjectContext 
{ 
if (__managedObjectContext != nil) 
{ 
    return __managedObjectContext; 
} 

NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; 
if (coordinator != nil) 
{ 
    __managedObjectContext = [[NSManagedObjectContext alloc] init]; 
    [__managedObjectContext setPersistentStoreCoordinator:coordinator]; 
} 
return __managedObjectContext; 
} 

- (NSManagedObjectModel *)managedObjectModel 
{ 
if (__managedObjectModel != nil) 
{ 
    return __managedObjectModel; 
} 
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Three20Test" withExtension:@"momd"]; 
__managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];  
return __managedObjectModel; 
} 

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator 
{ 
if (__persistentStoreCoordinator != nil) 
{ 
    return __persistentStoreCoordinator; 
} 

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Three20Test.sqlite"]; 

NSError *error = nil; 
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; 
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) 
{ 
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 
    abort(); 
}  

return __persistentStoreCoordinator; 
} 

#pragma mark - Application's Documents directory 

- (NSURL *)applicationDocumentsDirectory 
{ 
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory     inDomains:NSUserDomainMask] lastObject]; 
} 

@end 
+0

這聽起來很奇怪。你能告訴我們你的UIApplicationDelegate的代碼嗎? – aporat

+0

@aporat - 我編輯了我的文章並添加了appdelegate實現的源代碼 –

回答

0

映射視圖控制器

[map from:kAppRootURLPath toViewController:[HomeThumbnailViewController class]]; 

調用定義的ViewController

TTURLAction *urlAction=[[[TTURLAction alloc] initWithURLPath:strTTURL] autorelease]; 
urlAction.animated=YES; 
[[TTNavigator navigator]openURLAction:urlAction];