从TTTableview到TTPhotoView的导航



我有一个关于在Three20视图控制器导航的问题。我有TTTableView "Gallery"和TTPhotoViewController "Photos"。当我触摸一个表视图项目时,应用程序会导航到照片视图。

下面是我使用的代码:

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是一个表视图控制器

@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可以解决这个问题吗?

对于您的预期用途,您甚至不需要使用- from:parent:toSharedViewController:,只需尝试- from:toViewController:。这样做的原因是,你的方式到PhotoViewController是直接前进(启动器->图库->照片)。

如果你想从LauncherViewController直接导航到PhotoViewController,而在GalleryViewController之间(即在PhotoViewController的左上角有一个指向GalleryViewController的后退按钮),你想调用- from:parent:toSharedViewController:

当前,您正在调用- from:parent:toSharedViewController:,它将重用共享控制器,因此不会生成"嵌套推送"-警告:

以"share"模式创建的控制器,这意味着它将被创建一次,然后重复使用,直到被销毁。

最新更新