1. Ivan Andrus
  2. sage-iphone-app

Commits

Ivan Andrus  committed 28d57ce

Fixed crashing bug

  • Participants
  • Parent commits e887efa
  • Branches default

Comments (0)

Files changed (2)

File Classes/EditViewController.h

View file
     UIBarButtonItem *newButton;
     UIBarButtonItem *shareButton;
     UIActionSheet *actionSheet;
+    UILongPressGestureRecognizer *longPress;
 
     BOOL isFullScreenOutput;
     BOOL isLoaded;

File Classes/EditViewController.m

View file
 
     // Long press ((meant for eval button) but works anywhere in the
     // navigation bar) to select which language.
-    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
-                                               initWithTarget:self
-                                               action:@selector(selectLanguage:)];
+    longPress = [[UILongPressGestureRecognizer alloc]
+                 initWithTarget:self
+                 action:@selector(selectLanguage:)];
     longPress.minimumPressDuration = 1.0;
-    [self.navigationController.navigationBar addGestureRecognizer:longPress];
-    [longPress release];
 
     // Swipe to move cursor
     UISwipeGestureRecognizer *swipeRight =
 
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
+    [self.navigationController.navigationBar addGestureRecognizer:longPress];
 
     inputView.text = [selectedObject valueForKey:@"input"];
     [self updateOutput];
 }
 
 - (void)viewWillDisappear:(BOOL)animated {
+    [self.navigationController.navigationBar removeGestureRecognizer:longPress];
+
     // TODO: Maybe this is actually enough.  Maybe I don't need to poll in the javascript
     [self saveOutput:[outputView stringByEvaluatingJavaScriptFromString:@"isage_get_status()"]];
     [delegate saveEditViewForBackground:self];
                        @"Singular",
                        nil];
     }
-
     if ( isPhone ) {
         [actionSheet showInView:[UIApplication sharedApplication].keyWindow];
     } else if ( [sender isKindOfClass:[UILongPressGestureRecognizer class]]
     } else {
         self.navigationItem.rightBarButtonItem = nil;
     }
+    [longPress release];
     [actionSheet release];
     [newButton release];
     [evalButton release];