9

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!

4

4 に答える 4

21

それを必要とする人のために、自分でそれを理解しました:

最初に(ナビゲーターマップで「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を使用してViewControllerを呼び出すと、次のようになります。

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

2番目(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;
}

そして、あなたは完了です;)

于 2010-02-23T18:46:05.423 に答える
3

私はchoiseの答えを実装しようとしていて、多くのことを学び、最終的にはコールアウトを表示して、多くのURLで実装をシンプルに保つ必要があったので、これが私がしたことです。

  1. TableItemにURLを保持し、

  2. このコードは、TTTableViewControllerサブクラスで使用します。

    - (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath {
    
          NSLog(@"Its url is %@", [object URL]);
    
          TTURLAction *urlAction = [[[TTURLAction alloc] initWithURLPath:(NSString *)[object URL]] autorelease];
    
          urlAction.query = [NSDictionary dictionaryWithObject:self.user forKey:@"user"];
    
          urlAction.animated = YES;
    
          [[TTNavigator navigator] openURLAction:urlAction];
    
     }
    
     - (BOOL)shouldOpenURL:(NSString*)URL {
    
         return NO;
    
     }
    
  3. その「shouldOpenURL:」はTTTableViewControllerを調べて発見され、試してみたところ、機能しました。現在、テーブルビューは重複ビューを開いておらず、コールアウトがあります。

チョイスありがとう!

于 2010-12-31T09:25:55.200 に答える
0

選択の答えは、コードでTTURLActionを作成しているときに複数のパラメーターに対して機能しますが、ビューコントローラーへのリンクをTTStyledLabelに埋め込みたい場合はあまり役に立ちません.1つの解決策は、単一の文字列に複数のパラメーターを使用することです。

<a href='app://view2/param1=value1&param2=value2&...'>LabelName</a>

コードでそのようなURLを解析してパラメータを取得したい場合は、遠慮なくメッセージを送ってください。パーサークラスをお送りします。(または、NSScannerを使用して独自に作成することもできます!)

また、&sをエスケープすることを忘れないでください。そうしないと、TTStyledLabelはそれを望まないでしょう!

于 2011-05-17T21:08:56.290 に答える
0

TTTableViewControllerの現在のバージョン1.0.6.2でこれを実行する必要はありません。「URL」オプションは期待どおりに機能しています。それが機能しない場合は、URLが壊れているか、ViewControllerで間違った関数を呼び出しています。URLを介して呼び出す必要のある関数は、ViewControllerのID(ViewControllerのコンストラクター)を返す必要があります。その後、期待どおりに機能します。

TTNavigatorが期待するように、フォームの選択例を変更します。

TTNavigatorがナビゲートするために使用するマッピングを追加します。

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

URLセットを使用してTTTableLink(またはTTStyledTextなど)を作成します。これにより、マップが作成されます。

[TTTableLink itemWithText:@"TTTableLink" URL:@"tt://photos/1"]

これをPhotoVCに追加して、指定されたURLでTTNavigatorによって呼び出されるようにします

-(id) initWithNumber: (NSString*)number {
    if (self = [super init]) {
        self.title = @"Some Title";

        NSLog(@"%@",number);
    }

    return self;       
}

TTNavigatorは定義済みのコンストラクター関数tt:// photos /(initWithNumber :)を介してViewControllerを呼び出すため、関数didSelectObjectを上書きする必要はありません。

于 2012-08-16T19:10:58.260 に答える