0
我把歌曲变成一个表中的所有观点继续比赛,当我在详细页中工作中发挥的歌曲,当我回来的歌曲停,我想在所有视图如何使音乐在
继续发挥的ViewController
if let audio=NSBundle.mainBundle().pathForResource(navigationItem.title , ofType: "mp3") {
let url=NSURL (fileURLWithPath: audio)
do {
player = try AVAudioPlayer (contentsOfURL: url)
}
catch{"erorr"}
player.play()
} else {
print("erorr")
}
tableViewController
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.performSegueWithIdentifier("indeaa", sender: tableView)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "indeaa" {
let vc = segue.destinationViewController as UIViewController
let indexpath:NSIndexPath = tableaa.indexPathForSelectedRow!
vc.title = arr[indexpath.row]
}
}
因此,为了澄清,您有视图A继续查看B.视图B播放音频,并且当您导航回视图A时,音频停止。那是对的吗? – kpsharp
是........... –
查看下面的@toast的答案。这是你想要的。 – kpsharp