我試圖讓這種方法返回一個人,如果他們被選中。我的問題是,我得到一個錯誤,說委託不能返回除void
之外的其他類型,這很煩人,因爲我不想讓這個方法返回,除非這兩個動作中的一個發生了。有什麼建議麼?Monotouch導入聯繫人 - 返回類型問題
public static ABPerson ImportContact()
{
// Create placeholder for contact
ABPeoplePickerNavigationController _contactController = new ABPeoplePickerNavigationController();
AppDelegate.navigation.PresentViewController (_contactController, true, null);
_contactController.Cancelled += delegate {
AppDelegate.navigation.DismissViewController (true, null);
return;
};
_contactController.SelectPerson += delegate(object sender, ABPeoplePickerSelectPersonEventArgs e) {
_importedContact = e.Person.GetEmails().FirstOrDefault;
AppDelegate.navigation.DismissViewController (true, delegate {
return e.Person;
});
};
}
感謝您的幫助。我建議人們在我的示例中使用'PushViewController(view,animated)'而不是像上面那樣呈現,而@Maxim Korobov也是如此。關閉使用'PopViewControllerAnimated(動畫)' – BRogers 2013-03-01 00:24:47