如何重命名 AVPlayer 中的完成按钮?
How to rename Done button in AVPlayer?
我正在开发 Swift 3.0 中的应用程序,让用户有机会在线播放电视频道。当时它仅限于意大利,所以我试图用意大利语翻译应用程序中的每个按钮......但是我在顶部的完成按钮(和 "Live streaming" 字段)上遇到了问题每当用户选择要播放的频道时出现的 AVPlayer 屏幕。我确定有一种方法可以编辑它们,因为当我在 Safari 中打开流时,“完成”按钮正确显示为 "Fine" 并且 "Live streaming" 变为 "Trasmissione in diretta"... 我会我也喜欢这样看他们,但我不知道如何才能达到那个目标。
我没有为播放器做任何特定的 class,只是创建了一个从故事板到 AVPlayerController 的转接,我完全从包含频道的 table 视图管理流;这是我的重要代码:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "guardaCanale" {
let destinazione = segue.destination as! AVPlayerViewController
if let cellaCanaleSelezionata = sender as? CanaleTableViewCell {
let indexPath = tableView.indexPath(for: cellaCanaleSelezionata)!
let canaleSelezionato = ritornaIlCanaleCorretto(indexPath: indexPath)
let url = URL(string: canaleSelezionato.urlCanale)
if let streamingURL = url {
destinazione.player = AVPlayer(url: streamingURL)
// Il do-try-catch seguente serve per far funzionare l'audio dell'app anche se l'iPhone è in modalità silenziosa; togli il blocco per fare in modo che l'app non produca audio se l'iPhone è in modalità silenziosa
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
} catch {
print("Errore: non riesco a riprodurre l'audio se iPhone è in modalità silenziosa.")
}
destinazione.player?.play()
}
}
}
}
有人可以帮助我吗?我不想修改“完成”按钮的行为,只需更改其在屏幕上的可见名称...希望有人能帮助我!太感谢了! :)
听起来您没有正确设置您的应用程序以进行意大利语本地化。
Apple 提供的 UI 元素的翻译基于设备的语言以及您的应用程序是否支持该语言。如果您将设备语言更改为意大利语,这应该会自动显示。
我建议阅读 Apple's Localization Documentation 以确保您正确设置了您的应用程序,以便系统知道它已本地化为意大利语。
我正在开发 Swift 3.0 中的应用程序,让用户有机会在线播放电视频道。当时它仅限于意大利,所以我试图用意大利语翻译应用程序中的每个按钮......但是我在顶部的完成按钮(和 "Live streaming" 字段)上遇到了问题每当用户选择要播放的频道时出现的 AVPlayer 屏幕。我确定有一种方法可以编辑它们,因为当我在 Safari 中打开流时,“完成”按钮正确显示为 "Fine" 并且 "Live streaming" 变为 "Trasmissione in diretta"... 我会我也喜欢这样看他们,但我不知道如何才能达到那个目标。
我没有为播放器做任何特定的 class,只是创建了一个从故事板到 AVPlayerController 的转接,我完全从包含频道的 table 视图管理流;这是我的重要代码:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "guardaCanale" {
let destinazione = segue.destination as! AVPlayerViewController
if let cellaCanaleSelezionata = sender as? CanaleTableViewCell {
let indexPath = tableView.indexPath(for: cellaCanaleSelezionata)!
let canaleSelezionato = ritornaIlCanaleCorretto(indexPath: indexPath)
let url = URL(string: canaleSelezionato.urlCanale)
if let streamingURL = url {
destinazione.player = AVPlayer(url: streamingURL)
// Il do-try-catch seguente serve per far funzionare l'audio dell'app anche se l'iPhone è in modalità silenziosa; togli il blocco per fare in modo che l'app non produca audio se l'iPhone è in modalità silenziosa
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
} catch {
print("Errore: non riesco a riprodurre l'audio se iPhone è in modalità silenziosa.")
}
destinazione.player?.play()
}
}
}
}
有人可以帮助我吗?我不想修改“完成”按钮的行为,只需更改其在屏幕上的可见名称...希望有人能帮助我!太感谢了! :)
听起来您没有正确设置您的应用程序以进行意大利语本地化。
Apple 提供的 UI 元素的翻译基于设备的语言以及您的应用程序是否支持该语言。如果您将设备语言更改为意大利语,这应该会自动显示。
我建议阅读 Apple's Localization Documentation 以确保您正确设置了您的应用程序,以便系统知道它已本地化为意大利语。