我正嘗試使用iOS 7/8樣式模糊視圖控制器,該視圖控制器通過xamarin與故事板界面出現在視圖控制器上,並將其連接到導航控制器上,但我想實現的是用戶必須首先登錄,因此理論上菜單不應該先出現,但我希望我的登錄故事Board文件。如何以編程方式設置視圖控制器
其中xamarin在此基礎上https://github.com/romaonthego/REFrostedViewController
// 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();
},
},
},
},
};
內置AC尖銳libary但是,當我打開它去我的登錄查看它說以下
無法隱式轉換類型UI套件視圖控制器,因爲它期望ui視圖並且不能查看所以如何讓我的登錄屏幕出現在菜單顯示之前
我登錄查看班級
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();
// }
//}
}
}