簡體   English   中英

更改UIImagePickerController中的取消按鈕文本

[英]Change cancel button text in UIImagePickerController

我有個問題。 我想翻譯UIImagePickerController的取消按鈕。 我嘗試了不同的解決方案,但沒有一個起作用。

請找到我的實際代碼,該代碼可用於更改標題文本,但不適用於“取消”按鈕:

func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {    
    imagePicker.navigationBar.topItem?.title = localizedString("ES_CUSTOMERS_EDIT_PHOTOS_TITLE")

    imagePicker.navigationBar.backItem?.title = localizedString("ES_CANCEL_BUTTON")
}

單擊此處查看我要更改的內容

嘗試這個,

    func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {

         viewController.navigationItem.title = "your text..!!"    

    }

在Info.plist中,將Localisations屬性數組添加(或更改,如果已經存在)到您需要的數組(例如,西班牙語或德語或其他任何內容)

如果您使用cancel (或Interface Builder)的UIBarButtonItem.SystemItem設置了Cancel按鈕,它將像其他人一樣自動為您本地化。 如果出於某種原因要自行構建“取消”按鈕(如果文本僅為“取消”,則不需要/不建議使用),請使用合適的UIBarButtonItem構造函數,例如,基於屏幕截圖:

navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("Cancel", comment: "Cancel the action"), style: .plain, target: <appropriate target here>)

如果您不確定本地化在iOS中的工作方式,請參閱Apple 本地化您的App文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM