理解TTNavigator [英] understanding TTNavigator

查看:83
本文介绍了理解TTNavigator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的情况:



在TTTableViewController中,我添加了一些带有URL的单元格。
他们正在打开一个类例如 @tt:// photos。这个工作相当好。



第一件事是,我看到了一些url在TT的例子,如@tt / photos / 1。是可以在我的照片类中获取这个1,并说,例如,好吧,请打开图片一,是否只是另一个网址在TTNavigatior宣布打开一个特定的班?



另一件事是:是否可以将一个对象转发给链接类?
单击一个单元格打开@tt:// photos(在我的TTNavigator中的链接类)



使用正常的tableviews我可以覆盖我的init方法和



感谢!

使用我的初始化方法发送一个对象是否也可以通过点击我的TTItems?

首先(在导航器地图中传递subURLs)





导航到带有tt:// photos / firstphoto的网址是可能的,您可以像这样获取firstphoto:

  //像这样准备你的导航器地图
[map from:@tt:// photos /(initWithNumber :)toViewController :[PhotoVC class]];

在您的PhotoVC中,您可以访问此号码:

   - (void)initWithNumber:(NSString *)number {
NSLog(@%@,number);
}

使用此网址呼叫您的View Controller:

  PhotoVC * controller = [[PhotoVC alloc] initWithNumber:@1]; 
[navigationController pushViewController:controller animated:YES];
[controller release];

第二(在TTTableViewController中传递物件)



它有点棘手,但你不必子类任何东西。



首先,nil在TableItem中的URL

  [TTTableLink itemWithText:@TTTableLinkURL:nil] 

$您的TTTableViewController中的b
$ b

写下这个方法

   - (void)didSelectObject: object atIndexPath:(NSIndexPath *)indexPath {
TTURLAction * urlAction = [[[TTURLAction alloc] initWithURLPath:@tt:// photos] autorelease];
urlAction.query = [NSDictionary dictionaryWithObject:@firstphotoforKey:@photo];
urlAction.animated = YES;
[[TTNavigator navigator] openURLAction:urlAction];
}

现在您的PhotoVC中需要类似这样的

   - (id)initWithNavigatorURL:(NSURL *)URL query:(NSDictionary *)query {
if(self = [super init]) {
NSLog(@%@,query);
}

return self;
}

您已完成);


following situation:

in a TTTableViewController i added some Cells with URLs. they are opening a class with @"tt://photos" for example. this works quite fine.

the first thing is, i saw some urls in TT Examples like @"tt/photos/1". is it possible to fetch this "1" in my photos class and say, for example okay, please open picture one, ore is this only another URL that was declared in TTNavigatior to open a specific Class?

the other thing is: is it possible to forward an object to the linked class? clicking a cell opens @"tt://photos" (the linked class in my TTNavigator)

working with normal tableviews i can overwrite my init method and send an object with my initialize method, is this also possible by clicking my TTItems?

thanks!

解决方案

figured it out myself, for those who need it:

First (passing "subURLs" in your navigator map)

navigating to an URL with @"tt://photos/firstphoto" is possible, you can fetch the "firstphoto" like this:

//Prepare your Navigator Map like this
[map from:@"tt://photos/(initWithNumber:)" toViewController:[PhotoVC class]];

In your PhotoVC you can access this Number:

-(void) initWithNumber: (NSString*)number {
    NSLog(@"%@",number);
}

calling your View Controller with this url would look:

PhotoVC* controller = [[PhotoVC alloc] initWithNumber:@"1"];
[navigationController pushViewController:controller animated:YES];
[controller release];

Second (passing objects in an TTTableViewController)

its a bit tricky, but you dont have to Subclass anything.

first, nil the URL in the TableItem

 [TTTableLink itemWithText:@"TTTableLink" URL:nil]

in your TTTableViewController write down this method

- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath {
     TTURLAction *urlAction = [[[TTURLAction alloc] initWithURLPath:@"tt://photos"] autorelease];
     urlAction.query = [NSDictionary dictionaryWithObject:@"firstphoto" forKey:@"photo"];
     urlAction.animated = YES;
     [[TTNavigator navigator] openURLAction:urlAction];
 }

now in your your PhotoVC you need something like this

- (id)initWithNavigatorURL:(NSURL*)URL query:(NSDictionary*)query {
     if (self = [super init]) {
              NSLog(@"%@",query);
}

     return self;
}

and you are done ;)

这篇关于理解TTNavigator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆