解决iOS程序耳机有声音,外放没声音的问题

在AppDelegeate中添加如下代码:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        AppDelegate.instance = self
        
        let session = AVAudioSession.sharedInstance()
        do{
            try session.setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: AVAudioSessionCategoryOptions.MixWithOthers)
        } catch let err as NSError {
            NSLog(err.description)
        }
        
        return true
    }


你可能感兴趣的:(Ios,编程学习,Swift)