我正在研究 Monotouch/Xamarin 示例,并尝试将故事板 segue 和 Windows Azure 移动服务 (WAMS) 身份验证拼接在一起。我每个人都独立工作,但我似乎无法在有效的 WAMS 登录后触发 segue。DoLogin() 函数中不会引发错误,并且 AlertView 可以正常工作。它似乎只是跳过了 PerformSegue。ViewDidLoad() 中的 PerformSegue 工作正常。
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
btn_Facebook.TouchUpInside += (sender, e) => {
Console.WriteLine("Facebook clicked");
DoLogin(MobileServiceAuthenticationProvider.Facebook);
};
btn_Twitter.TouchUpInside += (sender, e) =>
{
Console.WriteLine("Twitter clicked");
this.PerformSegue("seg_Login", this);
// DoLogin(MobileServiceAuthenticationProvider.Twitter);
};
}
private void DoLogin(MobileServiceAuthenticationProvider provider)
{
string applicationKey = "[removed]";
string applicationUrl = "https://[removed].azure-mobile.net/";
MobileServiceClient client = new MobileServiceClient(applicationUrl, applicationKey);
var task = client.LoginAsync(this, provider).ContinueWith(t =>
{
MobileServiceUser user = t.Result;
this.BeginInvokeOnMainThread(() =>
{
this.PerformSegue("seg_Login", this);
UIAlertView alert = new UIAlertView("Logged In!", string.Format("Hello user {0}", user.UserId), null, "OK");
alert.Show();
});
});
}