Three20:如何在2个视图之间传递一类对象 [英] Three20 : how to pass a class of objects between 2 views
问题描述
我有一个TTableView。此表中的项目映射到一个URL,以便当我单击一个项目时,另一个视图显示有关此项目的信息。
所有这些信息都是类的属性。那么,我如何建立我的TTableTextItem URL以传输包含信息的类负责显示这些信息的视图?
I have a TTableView. The items in this table a mapped to an url, so that when I click on an item, another view appear with informations about this item. All these informations are attributes of a class. So, how can I build my TTableTextItem URL in order to transmit the class containing informations to the view responsible for the display of these informations ?
提前感谢。
推荐答案
一种方法是使用TTURLAction。当用户在表中选择一行时,它将调用你的didSelectObject(TTTableViewController)方法,提取要传递的对象或对象集,并构建一个TTURLAction,如下所示:
One way of doing it is to use a TTURLAction. When the user selects a row in your table, which will call your didSelectObject (of TTTableViewController) method, extract the object or set of objects you want to pass and build a TTURLAction like this:
TTURLAction *action = [[[TTURLAction actionWithURLPath:@"tt://showUser"]
applyQuery:[NSDictionary dictionaryWithObject:user forKey:@"kParameterUser"]]
applyAnimated:YES];
然后打开操作:
[[TTNavigator navigator] openURLAction:action];
您要作为此操作的结果打开的控制器应在您的TTURLMap中注册,一个构造函数因此:
The controller you want to open as a result of this action should be registered in your TTURLMap and should have a constructor thus:
- (id) initWithNavigatorURL:(NSURL*)URL query:(NSDictionary*)query {
self = [super init];
if (self != nil) {
self.user = [query objectForKey:kParameterUser];
}
return self;
}
我倾向于在我想要打开的对象的类上创建类别另一个控制器和显示器。
I tend to create categories on classes for objects I want to be able to open another controller and display themselves.
这篇关于Three20:如何在2个视图之间传递一类对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!