incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From becka...@apache.org
Subject git commit: Update contacts so displayContact closes properly
Date Wed, 25 Jan 2012 21:44:11 GMT
Updated Branches:
  refs/heads/master 135b0f5c2 -> 2c2897ea2


Update contacts so displayContact closes properly

Needed to rework the changes made for new iOS 5 apis to present
dismiss viewControllers.  Modified DisplayContactViewController to
override viewWillDismiss (rather than viewDidDismiss). This allows me to access
the parent viewController without needing to store it in the class itself.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/2c2897ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/2c2897ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/2c2897ea

Branch: refs/heads/master
Commit: 2c2897ea27ab9c66530dd796fa6880d6253fb79d
Parents: 135b0f5
Author: Becky Gibson <becka11y@apache.org>
Authored: Wed Jan 25 16:39:51 2012 -0500
Committer: Becky Gibson <becka11y@apache.org>
Committed: Wed Jan 25 16:39:51 2012 -0500

----------------------------------------------------------------------
 PhoneGapLib/Classes/Contacts.h |    9 +++++----
 PhoneGapLib/Classes/Contacts.m |   23 +++++++++++------------
 2 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/2c2897ea/PhoneGapLib/Classes/Contacts.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Contacts.h b/PhoneGapLib/Classes/Contacts.h
index 4f07a3f..4797c33 100755
--- a/PhoneGapLib/Classes/Contacts.h
+++ b/PhoneGapLib/Classes/Contacts.h
@@ -123,12 +123,13 @@
 @property (copy) NSString* callbackId;
 @end
 
-
+/* ABPersonViewController does not have any UI to dismiss.  Adding navigationItems to it
does not work properly,  thenavigationItems are lost when the app goes into the background.
 
+    The solution was to create an empty NavController in front of the ABPersonViewController.
This
+    causes the ABPersonViewController to have a back button. By subclassing the ABPersonViewController,
+    we can override viewWillDisappear and take down the entire NavigationController at that
time.
+ */ 
 @interface DisplayContactViewController : ABPersonViewController
 {
-
-    PGPlugin* contactsPlugin;  // needed in order to retrieve the appViewController to dismiss
the presented modalview
-
     
 }
 @property (nonatomic,retain) PGPlugin* contactsPlugin;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/2c2897ea/PhoneGapLib/Classes/Contacts.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Contacts.m b/PhoneGapLib/Classes/Contacts.m
index deb8d72..05b80c7 100755
--- a/PhoneGapLib/Classes/Contacts.m
+++ b/PhoneGapLib/Classes/Contacts.m
@@ -107,7 +107,7 @@
 	}
 
     if ([newPersonViewController respondsToSelector:@selector(presentingViewController)])
{ 
-        [[newPersonViewController presentingViewController] dismissModalViewControllerAnimated:YES];
+        [[newPersonViewController presentingViewController] dismissViewControllerAnimated:YES
completion:nil];
     } else {
         [[newPersonViewController parentViewController] dismissModalViewControllerAnimated:YES];
     }        
@@ -135,11 +135,10 @@
 		personController.displayedPerson = rec;
 		personController.personViewDelegate = self;
 		personController.allowsEditing = NO;
-        personController.contactsPlugin = self;  //pass in the PGPlugin object so can dismiss
the picker view later
 		
         // create this so DisplayContactViewController will have a "back" button.
         UIViewController* parentController = [[[UIViewController alloc] init] autorelease];
-        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:parentController];
+        UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:parentController]
autorelease];
 
         [navController pushViewController:personController animated:YES];
 
@@ -215,7 +214,7 @@
 		[self writeJavascript:[result toSuccessCallbackString: picker.callbackId]];
 		
         if ([picker respondsToSelector:@selector(presentingViewController)]) { 
-            [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
+            [[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
         } else {
             [[picker parentViewController] dismissModalViewControllerAnimated:YES];
         }        
@@ -237,7 +236,7 @@
 	[self writeJavascript:[result toSuccessCallbackString:picker.callbackId]];
 	
     if ([peoplePicker respondsToSelector:@selector(presentingViewController)]) { 
-        [[peoplePicker presentingViewController] dismissModalViewControllerAnimated:YES];
+        [[peoplePicker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
     } else {
         [[peoplePicker parentViewController] dismissModalViewControllerAnimated:YES];
     }        
@@ -492,16 +491,16 @@
 @synthesize contactsPlugin;
 
 
-- (void)viewDidDisappear: (BOOL)animated
+- (void)viewWillDisappear: (BOOL)animated
 {
-    [super viewDidDisappear: animated];
-    // I couldn't find the appViewController in the hierarchy of this UIViewController 
-    // so using the passed ContactPlugin to access it.
-    if ([self.contactsPlugin.viewController respondsToSelector:@selector(presentingViewController)])
{ 
-        [[self.contactsPlugin.viewController presentingViewController] dismissModalViewControllerAnimated:YES];
+    [super viewWillDisappear: animated];
+    
+    if ([self respondsToSelector:@selector(presentingViewController)]) { 
+        [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
     } else {
-        [[self.contactsPlugin.viewController parentViewController] dismissModalViewControllerAnimated:YES];
+        [[self parentViewController] dismissModalViewControllerAnimated:YES];
     }        
+    
 }
 -(void) dealloc
 {


Mime
View raw message