Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Do not dispose of the ABPeoplePickerNavigationController with a using…
Browse files Browse the repository at this point in the history
… block since it will be needed later
  • Loading branch information
spouliot committed Jan 13, 2012
1 parent ffdef08 commit d51e298
Showing 1 changed file with 45 additions and 41 deletions.
86 changes: 45 additions & 41 deletions MonoCatalog-MonoDevelop/AddressBookController.xib.cs
Expand Up @@ -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);
}
}
}

0 comments on commit d51e298

Please sign in to comment.