2016-06-11 3 views
0

iOS 7/8スタイルのぼかし表示コントローラーを、View Controllerの上に表示されるストーリーボードインターフェースのxamarinで使用しようとしています。ナビゲーションコントローラーに接続しました。しかし、私は達成したいと思っているユーザーは最初にログインする必要がありますので、理論的にはメニューは最初に表示されるべきではありませんが、ログインストーリーボードファイルが必要です。このhttps://github.com/romaonthego/REFrostedViewControllerView Controllerをプログラムで設定するにはどうすればいいですか

// Override FinishedLaunching. This executes after the app has started. 

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) 
    { 
     this.Window = new UIWindow(UIScreen.MainScreen.Bounds); 

     // ViewControllers 
     var aRootVC = new DEMOHomeViewController(); 
     var secondVC = new loginViewController(); 
     var loginViewControl = new loginViewController(); 

     //define the menu structure 
     var sections = new List<REMenuItemSection>() 
     { 

      new REMenuItemSection() 
      { 
       Items = new List<REMenuItem>() 
       { 
        new REMenuViewControllerItem() 
        { 
         //View exisiting view controller, will be reused everytime the item is selected 
         Icon = UIImage.FromBundle(@"home-48"), 
         Title = @"Home", 
         ViewController = loginViewControl, 
        }, 
        new REMenuViewControllerItem() 
        { 
         //New view controller, will be reused everytime the item is selected 
         Icon = UIImage.FromBundle(@"about-48"), 
         Title = @"Payments Missed", 
         ViewController = secondVC, 
        }, 
        new REMenuViewControllerItem() 
        { 
         //New view controller, will be reused everytime the item is selected 
         Icon = UIImage.FromBundle(@"about-48"), 
         Title = @"Payments Made", 
         ViewController = secondVC, 
        }, new REMenuViewControllerItem() 
        { 
         //New view controller, will be reused everytime the item is selected 
         Icon = UIImage.FromBundle(@"about-48"), 
         Title = @"Upload Doucments", 
         ViewController = secondVC, 
        }, 

         new REMenuViewControllerItem() 
        { 
         //New view controller, will be reused everytime the item is selected 
         Icon = UIImage.FromBundle(@"about-48"), 
         Title = @"Update Info", 
         ViewController = secondVC, 
        }, 

         new REMenuViewControllerItem() 
        { 
         //New view controller, will be reused everytime the item is selected 
         Icon = UIImage.FromBundle(@"about-48"), 
         Title = @"Amend I & E", 
         ViewController = secondVC, 
        } 
       }, 
      }, 
      new REMenuItemSection() 
      { 
       Title = "Friends Online", 
       Items = new List<REMenuItem>() 
       { 
        new REMenuActionItem() 
        { 
         //Action is called, on the UI thread, everytime the item is selected 
         Icon = UIImage.FromBundle(@"ask_question-48"), 
         Title = @"Logout", 
         Command =()=> 
         { 
          var uiAlert = new UIAlertView("Logout","Are you sure you want to log out?",null,"No","Yes"); 
          uiAlert.Show(); 
         }, 
        }, 
       }, 
      }, 
     }; 

に基づいて交流シャープlibaryを構築しました。しかし、私はそれが私のログインビューに行くために切り替えたとき、それは次のよう

が暗黙のうちに、UIキットビューにタイプを変換できませんと言うxamarin

コントローラーが表示されていないので、メニューが表示される前にログイン画面を表示させるにはどうすればいいですか?

enter image description here

enter image description here

マイログインビュークラス

public partial class loginViewController : UIView 
{ 
    const string serviceId = "ApertureBel"; 
    NSError error; 
    LAContext context = new LAContext(); 

    partial void touchButton(UIButton sender) 
    { 
     //Lets double check the device supports Touch I 
     if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out error)) 
     { 
      var replyHandler = new LAContextReplyHandler((success, error) => 
       { 
        InvokeOnMainThread(() => 
         { 
          if (success) 
          { 
       //    var homeScreen = (UIViewController)Storyboard.InstantiateViewController("welcome"); 
       //    PresentViewController(homeScreen, true,() => { }); 
          } 
          else 
          { 
           var alert = new UIAlertView("Finger Print!", "Sorry Finger Print is not on file.", null, "Aperturer", null); 
           alert.Show(); 
          } 
         }); 
       }); 
      context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Logging in with Touch ID", replyHandler); 
     } 
     else 
     { 
      var alert = new UIAlertView("Error", "TouchID not available", null, "Aperture", null); 
      alert.Show(); 
     } 
    } 


    bool CheckLogin(string username, string password) 
    { 
     if (password == Helpers.KeychainHelpers.GetPasswordForUsername(username, serviceId, true) && username == NSUserDefaults.StandardUserDefaults.ValueForKey(new NSString("username")).ToString()) 
      return true; 
     else 
     { 
      return false; 
     } 
    } 


    // partial void buttonLoginClick(UIButton sender) 
    //{ 
    // if (string.IsNullOrEmpty(txtUserName.Text) | string.IsNullOrEmpty(txtPassword.Text)) 
    // { 
    //  var alert = new UIAlertView("Oops!", "You must enter both a username and password", null, "Oops", null); 
    //  alert.Show(); 
    //  return; 
    // } 

    // if (CheckLogin(txtUserName.Text, txtPassword.Text)) 
    // { 
    //  var homeScreen = (UIViewController)Storyboard.InstantiateViewController("welcome"); 
    //  PresentViewController(homeScreen, true,() => { }); 
    // } 
    // else 
    // { 
    //  var alert = new UIAlertView("Login problem", "wrong username", null, "Oops...again", null); 
    //  alert.Show(); 
    // } 
    //} 
} 
} 

答えて

0

私はあなたのコードと同じロジックを持っています。 私の場合は、ログインする前にナビゲーションコントローラを隠しています。

使用あなたが最初のページ をロードし、あなたのLoginViewControllerでこのコード(ユーザーがログインしていないならば、非表示にします。)

this.NavigationController.SetNavigationBarHidden(true, true);//hide nav

あなたが成功にログインしているとき、ナビゲーションコントローラを示して!

this.NavigationController.SetNavigationBarHidden(false, true);//show nav メニューでコードを変更する必要がないように、〜

関連する問題