0
votes

Have a problem with an application using AVCam. The application takes photos and saves them to the roll. Upon opening the app it takes the pictures perfectly and saves them just the way it should. However, once I leave that view controller to go to another view controller and then return, it saves images normal portrait images rotated 90 degrees. Very odd activities indeed.

After lots of hair pulling, I thought maybe I'm trying to run too many sessions, so I make sure I end the sessions in viewdidload and the viewdiddisappear:

-(void)viewDidUnload{
if([[self captureManager] session ]){
    [[[self captureManager] session] stopRunning];
    self.captureManager = nil;
}
}

-(void)viewDidDisappear:(BOOL)animated{
if([[self captureManager] session ]&&rollCancel==NO){
    [[[self captureManager] session] stopRunning];
     self.captureManager = nil;
}
}

Still not working. Still saving incorrectly after leaving.

I change views like so: -(void)openMenu{
MenuViewController * vc = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil]; [self presentModalViewController:vc animated:YES]; [self dismissViewControllerAnimated:NO completion:nil]; }

Also tried:

-(void)openMenu{

[self dismissViewControllerAnimated:NO completion:^{
    MenuViewController * vc = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil];
    [self presentModalViewController:vc animated:YES];
    [self dismissViewControllerAnimated:NO completion:nil];
}];    
}

I don't need to release since I'm running on arc. This did not work as well, I wasn't even able to change screens with this option. SO, I added a timer to see if actions would keep acting after I leave the view controller:

updateTimer = [NSTimer timerWithTimeInterval: 5.0
                                      target: self selector: @selector(autoTimer)
                                    userInfo: nil repeats: YES];
[[NSRunLoop mainRunLoop] addTimer: updateTimer forMode: NSDefaultRunLoopMode];

-(void)autoTimer{
NSLog(@"blablabla");
}

And no big surprise, the blablabla continues to print into my console even after leaving the view controller. If I go back and forth, it will keep making new repeating timers and spam my console log.

This has got to have something to do with my application not saving correctly after returning to the screen. Which means that doing presentmodalviewcontroller does not actually remove everything from running.

Has anybody else ran into a similar issue like this or have any idea how to actually clear view controllers when switching between them?

1

1 Answers

0
votes

didn't resolve the NSTimer still running in the background, but did fix the landscape thing which had nothing to do with stuff being open in the background

Found the solution here: https://stackoverflow.com/a/6335992/1688727