Cant figure this one out. Everything works fine when the app is active, and than sometimes when i move the app to the background(pressing the home button) a
Roi,
I think your problem is that you are doing all the session setup and such in the viewWillAppear. Lets say that the captureSession, and the previewLayer were both alloc'd and working correctly. Now, you put app into the background and bring back.
You will immediately try to create a new captureSession, and a new previewLayer. I suspect that the old ones and the new ones are getting tangled up.
In the Apple AVCam example they do the setup in the viewDidLoad. That way it is only done once.
You should move all your setup stuff to a method and then call the method from the viewDidLoad.
bill