Ivan Andrus avatar Ivan Andrus committed 28d57ce

Fixed crashing bug

Comments (0)

Files changed (2)

Classes/EditViewController.h

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

Classes/EditViewController.m

 
     // 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];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.