In iOS 7 and ios 8,when start and then quickly stop recording voice,there will flash a red bar at the top of the screen.

I use some code of the speakhere example to record voice.

But in ios 7 and 8,when i start and then quickly stop the voice record,there will flash a red bar.

What can i do if i do not want it to show in the screen?


OSStatus error = AudioSessionInitialize(NULL, NULL, interruptionListener, self);

if (error)

{

printf("ERROR INITIALIZING AUDIO SESSION! %d\n", (int)error);

}

else

{

UInt32 category = kAudioSessionCategory_PlayAndRecord;

error = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category);

if (error)

{

printf("couldn't set audio category!");

}

error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, propListener, self);

if (error)

{

printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %d\n", (int)error);

}

UInt32 inputAvailable = 0;

UInt32 size = sizeof(inputAvailable);

error = AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &inputAvailable);

if (error)

{

printf("ERROR GETTING INPUT AVAILABILITY! %d\n", (int)error);

}

error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable, propListener,self);

if (error)

{

printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %d\n", (int)error);

}

error = AudioSessionSetActive(true);

if (error)

{

printf("AudioSessionSetActive (true) failed");

}

}