Red audio recording status bar "flashes" while app in *foreground* - ios8

There are many questions (here, here) regarding the double height red audio recording status bar, but all of them reference flashes when the app resigns into the background. I'm getting a flash, I'm assuming from an AVCaptureSession setup, while the app is in foreground.
Has anyone experienced this before?

You have to remove the audio input from the AVCaptureSession
[self.captureSession removeInput:audioIn];
in which the audioIn is the AVCaptureDeviceInputobject, that is initialised in the init method.
Explanation:
You get a flash because of the transition. When you go from view A to view B, and the object was allocated in view A. You get a flash because when the view B is presented, and view A still hasn’t deallocated the object. So it is still being used on “background” by view A. It’s the same thing when you are on a call and open an app while you are on a call.

Related

macOS, changing the size of a view controller by dragging

The user clicks a button and I present a new viewController as show.
Inside that VC there is a AVPlayerView, the same size as the VC.
The app itself can change size if the user drags any of its corners but the VC displaying the movie cannot.
Why things like that that should work by default, don't work as expected? What can be done to make this work?
Example:
This is the main app.
I can drag its corners and make it bigger or small. I can click on the green semaphore and make it full screen and it works fine.
When I press the Help icon, this "window" appears. It is a viewController that was added the story board.
This cannot be scaled. It "appears" to be a window, because it contains a semaphore. I cannot scale this but I can make it full screen by the green semaphore.
Note: I have added the view to a WindowController and now when the user presses the Help button this window controller is launched and the video appears. No change. Video cannot be scaled.
Found the problem.
I had to add a window controller controlling that View Controller.
View controller was not resizing even after #1.
Then I found that I could not have
self.preferredContentSize = CGSize(width: 940,height: 504)
inside awakeFromNib.
Now it works perfectly.
"The app itself can change size" –– what you're saying is that the window can be resized by the user.
"but the VC displaying the movie cannot" –– Again in this case, you're not trying to resize a view controller, you're trying to resize a window. The window contains your view controller.
The reason the window can't be resized is probably due to the layout constaints. I imagine there must be constraints somewhere in the view hierarchy which specifies that the video player (or some other view) has a specific width and height. Because it's a constant value, the window can't resize.

Entering full screen in MPMoviePlayerController calls viewWillDisappear and viewDidDisappear

To play video in my app, I set MPMoviePlayerController and add it to subview. The user can change to full screen mode using pinch gesture.
In this viewController (that contains the Movie Player View), I set the viewWillDisappear to set objects to nil.
But, in iOS 6, when activating fullscreen mode the MPMoviePlayerController in the view controller that contains the Movie Player View calls the methods viewWillDisappear and viewDidDisappear.
In iOS5, those methods were not called.
I came across this issue as well and it caused me a lot of headache. My temporary solution until the bug is fixed is to check the player's fullscreen Boolean value in viewWillDisappear: and/or viewDidDisappear:. If it returns YES, the movie is entering fullscreen mode and you should refrain from doing anything that might interrupt it.
To everyone has noticed that and having problem with this, I found this report in community Open Radar: http://openradar.appspot.com/12327997
I am not sure this is a question but in case someone has a problem with the issue herein stated, that is, someone using a viewController (that contains the Movie Player View), I found the solution:
I was using a view controller with the Movie Player Controller and then presented this view controller as a subview. I just got rid of it and used the MoviePlayer.view as a subview directly and it works just fine.
Not a problem with iOS 5, but now, it is. Fix it and enjoy!

XCODE play video from TableViewCell

I am using storyboards in XCODE4.
I am currently able to launch a video from a table cell using a push segue from a tableview controller to a viewcontroller. When the segue gets called, the view controller immediately launches the video using standard media player code in viewdidload. My problem is once the video is over, the app doesn't return to the table cell, instead it stays at the blank table view controller until a user clicks "Back".
Anyone know a simple way to have the video end and switch back to the TableViewController?
Apple didn't make this one easy. My assumption is that they want the user to choose to exit the movie player when s/he feels comfortable enough to do it (and then the user would have the choice to replay or skip back to parts that they might want to see again).
But one way to catch the end of the movie happening would be to register for the "MPMoviePlayerPlaybackDidFinishNotification" notification (documentation linked for you) and then exit and/or remove the MPMoviePlayerController.
Note: this notification also fires if there's any error while loading the movie (see the documentation for initWithContentURL:).

Stop Device orientation

While running my app I get errors which indicate that rotation notifications are being sent and crashing the app. Is there a way I can stop all rotation events from being sent to see if I can stop the crashes. Also is there a good overview of how these events should be handled. Do I have to handle them separately in in controllers or in all views. For the moment I would be quite happy to lock in portrait.
I have tried calling [[UIDevice currentDevice] endGenerating Device OrientationNotifications];
but I am still getting device Orientation DidChange events unrecognized selector sent to instance
You can't stop rotation notifications, nor should you try to.
The notifications aren't causing your crash, you must have some bad code in there.
Paste your exact error from the console and the code for the view controller where it's happening. My guess is that you've written a rotation handler method that doesn't work, possibly without realising it.
You can lock in portrait by creating a view controller base class that has this method, then using it as the superclass for all your other view controllers:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}

How do YOU implement a setup screen?

As per the tags indicate I'm developing in Xcode for the iPad.
So, I have a New Game setup screen that sits between my main menu screen and the actual game screen. The new game setup screen is supposed to allow the user to customize their game by selecting the number of players, choosing an avatar for each and setting their names. What I've done is I've setup the continue button to write all the settings to a appData.plist file before moving onto the actual game screen. When the game screen appears (the viewDidLoad method) it reads from the plist to add the players to the table with their respective Avatars and so forth.
The question is, is this the right way to pass the data from a new game setup screen to the game screen? Should I use some method to gather the information from the screen and pass it along to the game screen without writting to some file? I guess the ultimate question is how you're supposed to pass data from one view controller to another? I'm using some plist file to write to and then read from when the board appears. I get a sneaking suspicion that this is not the right way to do this. However, I figure at some point I need to save this data to file anyway since I have to be able to restore the state of my app in the even that it gets closed or interrupted. But what is YOUR preferred method to accomplish this?
You can always use the built-in settings screen for your app by making use of the Settings.bundle too. This is very easy and allows you to use the default iPad settings screen for your application settings, rather than setting up a hand-made one.
For passing through information, the information I need is usually a single object (in your case maybe Player.m) and so I create a property in the next view to hold this. And before showing the view I then do (for instance):
GameViewController *gameView = [[GameViewController alloc] initWithNibName:#"GameViewController" bundle:[NSBundle mainBundle]];
gameView.player = player;
[self.navigationController pushViewController:gameView animated:YES];
[gameView release];

Resources