gpt4 book ai didi

iphone - 理解TTNavigator

转载 作者:太空狗 更新时间:2023-10-30 03:27:38 24 4
gpt4 key购买 nike

以下情况:

在 TTTableViewController 中,我添加了一些带有 URL 的单元格。例如,他们正在用 @"tt://photos" 开设一个类。这很好用。

首先,我在 TT 示例中看到了一些 url,例如 @"tt/photos/1"。是否可以在我的照片类中获取这个“1”并说,例如,好吧,请打开图片一,或者这只是在 TTNavigatior 中声明的另一个打开特定类的 URL 吗?

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

使用普通的 tableviews 我可以覆盖我的 init 方法并使用我的初始化方法发送一个对象,这也可以通过单击我的 TTItems 来实现吗?

谢谢!

最佳答案

我自己想出来,给需要的人:

首先(在导航器 map 中传递“subURLs”)

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

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

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

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

用这个 url 调用你的 View Controller 会是:

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

其次(在 TTTableViewController 中传递对象)

这有点棘手,但您不必对任何东西进行子类化。

首先,将 TableItem 中的 URL 归零

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

在你的 TTTableViewController 中写下这个方法

- (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];
}

现在在你的 PhotoVC 中你需要这样的东西

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

return self;
}

你就完成了;)

关于iphone - 理解TTNavigator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2317754/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com