【问题标题】:Multi-parameter mapping with Three20 and TTURLMap使用 Three20 和 TTURLMap 进行多参数映射
【发布时间】:2010-07-05 23:01:40
【问题描述】:

我正在关注this 教程并在我的应用委托中声明以下映射:

[map from:@"x://profile/(initWithId:)/(name:)" toViewController:[ProfileViewController class]];
[map from:@"*" toViewController:[TTWebController class]];

ProfileViewController.m 中,我实现了- (id)initWithId:(int)anIdentifier name:(NSString *)name 选择器来处理此类映射。我想打开像x://profile/1/John Doe 这样的URL 会调用[[ProfileViewController alloc] initWithId:1 name:@"John Doe"],但是,情况似乎并非如此。每次打开 URL 时都会调用默认的 TTWebController 类。

使用单个参数,即x://profile/(initWithId:) 之类的东西是正确的,即调用[[ProfileViewController alloc] initWithId:1]

我在这里错过了什么吗? Three20和TTURLMap如何使用多参数映射?

【问题讨论】:

  • 你需要使用 toViewController: 来传递数据,还是你也可以使用 toModalViewController: ?因为我正在使用 toModalViewController: 并传递一些数据,而当我使用的 initWithId: 方法被调用时,由于某种原因它实际上并没有打开视图。

标签: iphone objective-c three20


【解决方案1】:

问题在于“x://profile/1/John Doe”的 URL 格式不正确。当您构建 URL 时,请尝试以下操作:

NSString *URL = [NSString stringWithFormat:@"x://profile/%d/%@", 1,
                 [@".." stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];

享受吧!

/mtr

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-06
    • 2012-06-22
    • 2021-09-13
    • 2011-06-28
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 2019-11-26
    相关资源
    最近更新 更多