SBStatusBarController实例

有人可以帮我小样本如何获得SBStatusBarController实例吗? 我看了很多论坛和源代码,它不适合我:(

谢谢。

好吧,我已经find了如何显示双高度状态栏,如没有SpringBoard的In-Call状态栏,并使用合法手段。 这是一个解决scheme。 在应用程序处于baground模式时,有两种方式显示应用程序名称的双重状态栏:使用套接字连接到VoIP服务或模拟录音。 使用第一种方法,你会看到绿色的发光状态栏,如果你喜欢红色,你必须使用第二个。 好的,我使用第二种方法并执行录音模拟。 为了达到这个目的,只需将以下string添加到应用程序的PLISTconfiguration文件:

<key>UIBackgroundModes</key> <array> <string>voip</string> <string>audio</string> </array> 

它会告诉iOS你的应用程序将在后台使用audio和VoIP。 现在代码。 我们将模拟从麦克风到NULL设备的录音:

 - (void) startRecording { AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *err = nil; [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err]; if(err){ NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]); return; } [audioSession setActive:YES error:&err]; err = nil; if(err){ NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]); return; } recordSetting = [[NSMutableDictionary alloc] init]; [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey]; [recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey]; [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey]; NSURL *url = [NSURL fileURLWithPath:@"/dev/null"]; err = nil; recorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&err]; if(!recorder){ NSLog(@"recorder: %@ %d %@", [err domain], [err code], [[err userInfo] description]); UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Warning" message: [err localizedDescription] delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; return; } //prepare to record [recorder setDelegate:self]; [recorder prepareToRecord]; recorder.meteringEnabled = YES; BOOL audioHWAvailable = audioSession.inputIsAvailable; if (! audioHWAvailable) { UIAlertView *cantRecordAlert = [[UIAlertView alloc] initWithTitle: @"Warning" message: @"Audio input hardware not available" delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [cantRecordAlert show]; [cantRecordAlert release]; return; } // start recording [recorder record];//recordForDuration:(NSTimeInterval) 40]; } 

将此方法添加到您的应用程序委托,并从didFinishLaunchingWithOptions调用它。 另外,据我所知,你可以将audio会话类别设置为AVAudioSessionCategoryPlayAndRecord并使其处于活动状态。 如果您将此代码添加到您的项目,那么万一您将您的应用程序置于后台,您将会看到内部带有应用程序名称的双高度状态栏。

我想就是这样。

谢谢。