I have a question regarding view controller navigations in Three20. I have a TTTableView “Gallery” and TTPhotoViewController “Photos”. When I touch inside one table view item, the app will navigate to a photo view.
Here are the code I used:
In the AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method,
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];
The GalleryViewController is a tableview Controller
@interface GalleryViewController : TTTableViewController
@end
In the 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];
}
I copied this code from the TTCatalog.xcodeproj sample project. But I cannot drill into the photo view and got the following from the console when I try to navigate to photo view from the table view item.
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>.
So I don’t know how to solve this question. Thanks!
——–Update:———-
I figured out how to solve the problem. In the AppDelegate methods, use
[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];
instead of the [map from: parent: toViewController: selector: transition:]
But here comes another question, can someone explain why the toSharedViewController can solve this problem?
For your intended use, you don’t even need to use
- from:parent:toSharedViewController:, just try- from:toViewController:. The reason for this is that your way to thePhotoViewControlleris straight forward (Launcher -> Gallery -> Photo).For the case that you want to navigate to the
PhotoViewControllerdirectly from theLauncherViewControllerwhile having theGalleryViewControllerin between (i.e. having a back-button on the top left of yourPhotoViewControllerpointing to theGalleryViewController), you want to call- from:parent:toSharedViewController:.Currently, you are calling
- from:parent:toSharedViewController:, which will reuse the shared controller, thus not generating the “nested push”-warnings: