2016-06-09 2 views
0

Android 앱을 iOS로 변환 중입니다. 이미 로그인 화면을 만들었고 사용자가 로그인 할 수 있습니다. 정확한 자격 증명을 입력하면 그의 데이터는 NSUSerDefault을 사용하여 저장됩니다.부팅시 사용자 로그인 상태에 따라 다른 스토리 보드 시작 (Xamarin.iOS)

내가 모르는 것은 앱을 시작할 때 값을 NSUserDefault에서 확인하고 사용자가 로그인해야하는지 여부를 결정하는 방법입니다.

Segues는 프로그래밍 방식으로 안드로이드 (StartActivity())처럼 만들 수 없으므로 어떤 문제가 발생했을 때 해결책이 될만한 버튼이나 비슷한 것이 필요합니까? AppDelegate 클래스

+0

당신은 아마 2 개의 다른 스토리 보드가 필요하지 않습니다. 난 항상 로그인보기 컨트롤러로 시작하고 그 자격 증명을 확인하자. 성공하면 다음보기 컨트롤러를 밀어서 스택에서 자신을 제거합니다. 이것은 정말로 당신의 계층에 달려 있지만, 당신은'UINavigationController'를 사용하고 있습니까? 그렇지 않으면 뷰 컨트롤러를 대체하기 위해 앱 델리게이트의'Window.RootViewController'를 변경할 수 있습니다. 참고로 'NSUserDefault'는 자격 증명을위한 좋은 장소가 아닙니다. 자격증 명은 키 체인에 속합니다. – dylansturg

답변

0

:

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) 
     { 

      // Override point for customization after application launch. 
      // If not required for your application you can safely delete this method 


      UIViewController yourViewController = UIStoryboard.FromName("yourStoryboard",NSBundle.MainBundle).InstantiateViewController("yourViewController_StoryboardID"); 


      this.Window = new UIWindow(UIScreen.MainScreen.Bounds); 
      UINavigationController navigationController = new UINavigationController(yourViewController); 

      this.Window.RootViewController = navigationController; 
      this.Window.MakeKeyAndVisible(); 


      return true; 
     } 
관련 문제