2014-03-04 2 views
1

저는 Xamarin IOS를 처음 사용하고 있으며이 플라이 아웃 탐색이 필요한 프로젝트가 있습니다.xamarin에서 플라이 아웃 탐색을 사용하는 방법 IOS

var navigation = new FlyoutNavigationController { 
        // Create the navigation menu 
        NavigationRoot = new RootElement ("Navigation") { 
         new Section ("Menu") { 
          new StringElement ("Recipe"), 
          new StringElement ("Recipe Basket"), 
          new StringElement ("Meal Planner"), 
          new StringElement ("Grocery List"), 
          new StringElement ("Social"), 
          new StringElement ("Videos"), 
          new StringElement ("News Feed"), 
          new StringElement ("Partners"), 
         } 
        }, 
        // Supply view controllers corresponding to menu items: 

        ViewControllers = new [] { 
         new UIViewController { View = new UILabel { Text = "Animals (drag right)" } }, 
         new UIViewController { View = new UILabel { Text = "Vegetables (drag right)" } }, 
         new UIViewController { View = new UILabel { Text = "Minerals (drag right)" } }, 


        }, 
       }; 

이 코드는 UILabel을 제공합니다. 특정 뷰 컨트롤러로 보내려면 어떻게해야합니까?

도와주세요.

미리 감사드립니다.

답변

0

당신은 단지 UILabel의이 제시 당신의 View

// Show the navigation view 
navigation.ToggleMenu(); 
View.AddSubview (navigation.View); 
0

이 코드에 FlyoutNavigationController's View을 추가해야합니다.

새 UIViewController에 대한보기로만 UILable을 제공하기 때문에.

View = new UILabel { Text = "Animals (drag right)" } 

어떻게이 특정 뷰 컨트롤러로 전송하기 위해 무엇을 할 수 있는가? 이 당신을 도와

ViewControllers = new [] { 
         new UIViewController { View = new UILabel { Text = "Animals (drag right)" } }, 
         new UIViewController { View = new UILabel { Text = "Vegetables (drag right)" } }, 
         new UIViewController { View = new UILabel { Text = "Minerals (drag right)" } }, 

       }, 

희망

ViewControllers = new [] { 
          new <your_UIViewController>(), 
          new <your_UIViewController>(), 
          new <your_UIViewController>(), 

        }, 

는 예를 들어 대신 새로운 UIViewController에

의 당신의 UIViewController는 다음과 같은 코드를 변경 제공, 당신이 어떤 직면 있으면 알려 주시기 문제를 구현하는 동안

+0

f inal 출력. 아이폰에 어떻게 나타나는지. 왼쪽 네비게이션 바 버튼 항목을 4 개의 가로 막대로 표시하지만 가져 오지 못하게하고 싶습니다. 그러면 스크린 샷을 게시 할 수 있습니까? 감사합니다. – RookieAppler

+0

안녕하세요. 스크린 샷을 공유 할 수 있었으면 좋지만, 웬일인지 공유 할 수있는 힘이 없습니다. 플라이 아웃 탐색은 슬라이드 메뉴와 유사하게 작동합니다. 왼쪽 탐색 모음 단추는 "NavigationItem.LeftBarButtonItem"입니다. – vinaykumar

1

vinaykumar가 말한 바를 수행하지만, UIViewControllers에서 FlyoutNavigationController를 열고 싶으므로 작성한 초기 컨트롤을 해당 컨트롤러로 전달해야합니다.

그렇지 않으면보기 컨트롤러를 방금 열면 메뉴를 다시 가져올 수 없습니다. 있는 viewDidLoad에

MainViewController을 :

내가 지금처럼 네비게이션 컨트롤러를 개방하고있어, 다른 뷰 컨트롤러에서

 UIStoryboard board = UIStoryboard.FromName("MainStoryboard_iPhone", null); 

     UINavigationController nav = (UINavigationController)board.InstantiateViewController("nav"); 
     SearchViewController searchVC = (SearchViewController)nav.ViewControllers[0]; 

     // Passing flyoutnavigation here 
     searchVC.navigation = navigation; 

     SettingsViewController settingsVC = (SettingsViewController)board.InstantiateViewController("settings"); 
     UINavigationController navSettings = new UINavigationController(settingsVC); 

     // Passing flyoutnavigation here 
     settingsVC.navigation = navigation; 

     navigation.ViewControllers = new[] 
     { 
      nav, 
      navSettings 
     }; 

(설정을 내 예를 찾아), 나는 저장하는 공용 변수를 FlyoutNavigationController (MainViewController에서 설정)를 호출 한 후 FlyoutNavigationController를 열려면 버튼을 추가합니다.

// Set in MainViewController 
    public FlyoutNavigationController navigation; 

    public override void ViewDidLoad() 
    { 

     base.ViewDidLoad(); 

     // Add button to allow opening the FlyoutNavigationController 
     NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, delegate 
     { 
      navigation.ToggleMenu(); 
     }); 
    } 
관련 문제