respond to hyperlinks in Three20 TTStyledTextLabel iphone
Im using the of Three20 source code to show hyperlinks from text I get from twitter, so far I've managed to map the "*" URLs to the class TTWebViewController using.
[map from:@"*" toViewController:[TTWebController class]];
But I also want to be able to return to the previous view (where the twitter feed is being shown), This is done in the TTTwitter sample project but I don't understand how its done, it all seems very obscure to me and I haven't find anything in the documentation.
I don't really understand why they map every class to an URL, and how the navigator knows how to initiate and manage the different classes, for example in my case I never have control over the TTWebController, because I could have a wrapper class that intantiates the webController and place it inside a UINavigationController but I wouldn't know the twitter URL that I n开发者_StackOverflow社区eed to load;
Any pointers would be appreciated, also if someone knows a good Three20 tutorial would be great.
When using TTNavigator we should create all our view controllers using TTNavigator.And for that we should map all our view controller to url schemes.
When TTNavigator is called for the first time in an app (in your case through the TTStyledLabel) it creates a base navigation controller.You dont see a back button since you are in a whole new navigation controller.
Therefore you should map your Twitter feed view controller to a url and ask TTNavigator to open that URL in your app delegate.
Something like this in your app delegate should work for you.
TTNavigator* navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeNone;
[self.window makeKeyAndVisible];
TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]];
[map from:@"app://feed" toViewController:[TwitterFeedViewController class]];
if (![[TTNavigator navigator] restoreViewControllers]) {
TTURLAction* urlAction = [TTURLAction actionWithURLPath:@"app://feed"];
[TTNavigator navigator] openURLAction:urlAction];
}
精彩评论