2011-10-30 30 views
0

我有一个关于Three20中的视图控制器导航的问题。我有一个TTTableView“图库”和TTPhotoViewController“照片”。当我触摸一个表格视图项目时,该应用程序将导航到照片视图。从TTTableview到TTPhotoView的Three20导航

下面是我使用的代码:

AppDelegate.m- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法,

TTNavigator *navigator = [TTNavigator navigator]; 
navigator.supportsShakeToReload = NO; 
navigator.persistenceMode = TTNavigatorPersistenceModeAll; 


TTURLMap *map = navigator.URLMap; 
[map from:@"*" toViewController:[TTWebController class]]; 

[map from:@"tt://launcher" toSharedViewController:[LauncherViewController class]]; 

[map from:@"tt://photos" parent:@"tt://gallery" toViewController:[PhotoViewController class] selector:nil transition:0]; 
[map from:@"tt://gallery" parent:@"tt://launcher" toViewController:[GalleryViewController class] selector:nil transition:0]; 

的GalleryViewController是一个的tableview控制器

@interface GalleryViewController : TTTableViewController 
@end 

GalleryViewController.m

-(void)createModel 
{ 
    self.dataSource = [TTListDataSource dataSourceWithObjects: 
        [TTTableSubtitleItem itemWithText:@"Album One" subtitle:nil imageURL:@"http://example.image.url" URL:@"tt://photos"] 
        , 
        [TTTableSubtitleItem itemWithText:@"Album Two" subtitle:nil imageURL:@"http://example.image.url2" URL:@"tt://photos"], 
        nil]; 
} 

我从TTCatalog.xcodeproj示例项目复制了此代码。但是当我尝试从表格视图项目导航到照片视图时,我无法钻入照片视图并从控制台获得以下内容。

nested push animation can result in corrupted navigation bar 
Finishing up a navigation transition in an Navigation Bar subview tree might get corrupted. 
Unbalanced calls to begin/end appearance transitions for <PhotoViewController: 0x6c5d8f0>. 

所以我不知道如何解决这个问题。谢谢!

--------更新:----------

我想通了,如何解决这个问题。在AppDelegate方法,使用

[map from:@"tt://launcher" toSharedViewController:[LauncherViewController class]]; 

[map from:@"tt://photos" parent:@"tt://gallery" toSharedViewController:[PhotoViewController class] selector:nil]; 
[map from:@"tt://gallery" parent:@"tt://launcher" toSharedViewController:[GalleryViewController class] selector:nil]; 

代替[map from: parent: toViewController: selector: transition:]

但这里说到另外一个问题,有人可以解释为什么toSharedViewController可以解决这个问题?

回答

0

为了您的预期用途,您甚至不需要使用- from:parent:toSharedViewController:,只需尝试- from:toViewController:即可。这是因为你通往PhotoViewController的路很简单(启动器 - >图库 - >照片)。

对于要同时具有两者之间的GalleryViewController(即具有对您PhotoViewController左上方指向GalleryViewController一个后退按钮)来从LauncherViewController导航到PhotoViewController直接的情况下,你要调用- from:parent:toSharedViewController:

目前,要调用- from:parent:toSharedViewController:,这将重用共享控制器,从而不生成所述“嵌套推” -warnings:用“共享”模式下创建

控制器,这意味着它将是 创建一次并重新使用,直到它被销毁。