0

私はiosの初心者です。私はUITabbarControllerでの作業を試みましたが、TabControlのデータをTabbarの項目である別のViewControllerに渡してみると、問題が発生しました。この場合、私はボタンのログインをクリックすると、 "お店へようこそ"が表示され、ログインフォームのユーザー名が "お店へようこそ"のラベルに渡されます。 you can see picture below for more detailsUITabbarControllerでpresentViewControllerを使用するとデータを渡す方法

私が登場するコントローラ「買い物をするようこそ」を作るために以下のコードを使用します。ラベル(WelcomeToShopController)に(LoginControllerで)ユーザー名を渡すことに

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    UITabBarController *tabbarController= [storyboard instantiateViewControllerWithIdentifier: @"tabbarID"]; 
    [self presentViewController: tabbarController animated: YES completion: nil]; 

だから、私のための任意のアイデアを?

答えて

1

私が調査した後、私の問題は解決しました:)。私はtabbarとnavigationControllerを使用していたので、インスタンスtabbar - > NavigationController - > ViewControllerを使うべきです。私の場合、以下のコードは完全に動作します。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    UITabBarController *tabbarController= [storyboard instantiateViewControllerWithIdentifier: @"tabbarID"]; 
    UINavigationController *nav = (UINavigationController *)[tabbarController.viewControllers firstObject]; 
    HistoryOrderingController *historyOderingVC = (HistoryOrderingController *)[[nav viewControllers] firstObject]; 
    historyOderingVC.user = self.user; 
    [self presentViewController: tabbarController animated: YES completion: nil]; 
関連する問題