1

UITableView左のスライドバーでJTRevealSidebar V2 を使用しています。

メッセージを送信して他の ViewController にプッシュする方法がわかりません。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.sidebarDelegate) {
       NSString *text = [self.leftList objectAtIndex:indexPath.row];
        if ([text isEqual:@"Warenkorb"]) {
            NSLog(@"Ist warenkorb");
           // How to push/create/bring2top view of msCartViewController Identified by "Cart"?
           // NSLog works
        }
    }
}

これはどのように行うことができますか?

4

2 に答える 2

1

rootviewcontroller で、新しい UIViewController を割り当ててから、それを UINavigation スタックにプッシュします。

例えば:

UIViewController *myViewController = [[UIViewController alloc] init];

myViewController.title = @"My First View";

myViewController.view.backgroundColor = [UIColor redColor];

//to push the UIView.

[self.navigationController pushViewController:myViewController animated:YES];

ルート ビュー コントローラーでこれを行うことを忘れないでください。お役に立てれば。

于 2013-03-12T21:41:42.270 に答える
0

おそらく、あなたの問題は、ストーリーボードでmsCartViewControllerを「カート」と呼んでいるように、ストーリーボードからインスタンスを取得する方法です。

または、プッシュ用のナビゲーションコントローラーを取得できない場合があります。

最初の問題の場合

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
msCartViewController* vc=[storyboard instantiateViewControllerWithIdentifier:@"Cart"];

2 番目の問題については、シングルトンの辞書プロパティなど、アクセスできる場所にナビゲーション コントローラー ポインターを格納する必要があります。と同じように

// at first make a singleton with a dictionary property. here I call it YourNavigationCenter

UINavigationController *navigationController = [YourNavigationCenter sharedCenter].navigationDictionary[@"yourNavigationName"];
[navigationController pushViewController:self animated:YES];

これらの解決策があなたの主張を理解していない場合は、コメントしてください。

于 2018-06-21T03:34:01.813 に答える