Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Do not dispose of the ABPeoplePickerNavigationController with a using…

… block since it will be needed later
  • Loading branch information...
commit d51e298b269e90fe0ec2470acb57788f2e2719e9 1 parent ffdef08
@spouliot spouliot authored
Showing with 45 additions and 41 deletions.
  1. +45 −41 MonoCatalog-MonoDevelop/AddressBookController.xib.cs
View
86 MonoCatalog-MonoDevelop/AddressBookController.xib.cs
@@ -17,55 +17,59 @@ public AddressBookController () : base ("AddressBookController", null)
{
}
- public override void ViewDidLoad ()
- {
- }
-
- public override void ViewWillAppear (bool animated)
+ protected override void Dispose (bool disposing)
{
+ if (p != null) {
+ p.Dispose ();
+ p = null;
+ }
+ base.Dispose (disposing);
}
- public override void ViewWillDisappear (bool animated)
+ ABPeoplePickerNavigationController GetPicker ()
{
+ if (p != null)
+ return p;
+
+ p = new ABPeoplePickerNavigationController ();
+ p.SelectPerson += (o, e) => {
+ Console.Error.WriteLine ("# select Person: {0}", e.Person);
+ toString.Text = e.Person.ToString ();
+ firstName.Text = e.Person.FirstName;
+ lastName.Text = e.Person.LastName;
+ property.Text = "";
+ identifier.Text = "";
+ e.Continue = selectProperty.On;
+ if (!e.Continue)
+ DismissModalViewControllerAnimated (true);
+ };
+ p.PerformAction += (o, e) => {
+ Console.Error.WriteLine ("# perform action; person={0}", e.Person);
+ toString.Text = e.Person.ToString ();
+ firstName.Text = e.Person.FirstName;
+ lastName.Text = e.Person.LastName;
+ property.Text = e.Property.ToString ();
+ identifier.Text = e.Identifier.HasValue ? e.Identifier.ToString () : "";
+ e.Continue = performAction.On;
+ if (!e.Continue)
+ DismissModalViewControllerAnimated (true);
+ };
+ p.Cancelled += (o, e) => {
+ Console.Error.WriteLine ("# select Person cancelled.");
+ toString.Text = "Cancelled";
+ firstName.Text = "";
+ lastName.Text = "";
+ property.Text = "";
+ identifier.Text = "";
+ DismissModalViewControllerAnimated (true);
+ };
+ return p;
}
- partial void showPicker (MonoTouch.UIKit.UIButton sender)
+ partial void showPicker (MonoTouch.UIKit.UIButton sender)
{
Console.Error.WriteLine ("# Select Contacts pushed!");
- using (p = new ABPeoplePickerNavigationController ()) {
- p.SelectPerson += (o, e) => {
- Console.Error.WriteLine ("# select Person: {0}", e.Person);
- toString.Text = e.Person.ToString ();
- firstName.Text = e.Person.FirstName;
- lastName.Text = e.Person.LastName;
- property.Text = "";
- identifier.Text = "";
- e.Continue = selectProperty.On;
- if (!e.Continue)
- DismissModalViewControllerAnimated (true);
- };
- p.PerformAction += (o, e) => {
- Console.Error.WriteLine ("# perform action; person={0}", e.Person);
- toString.Text = e.Person.ToString ();
- firstName.Text = e.Person.FirstName;
- lastName.Text = e.Person.LastName;
- property.Text = e.Property.ToString ();
- identifier.Text = e.Identifier.HasValue ? e.Identifier.ToString () : "";
- e.Continue = performAction.On;
- if (!e.Continue)
- DismissModalViewControllerAnimated (true);
- };
- p.Cancelled += (o, e) => {
- Console.Error.WriteLine ("# select Person cancelled.");
- toString.Text = "Cancelled";
- firstName.Text = "";
- lastName.Text = "";
- property.Text = "";
- identifier.Text = "";
- DismissModalViewControllerAnimated (true);
- };
- PresentModalViewController (p, true);
- }
+ PresentModalViewController (GetPicker (), true);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.