Cropped characters - iOS11 - Alert Dialog

2019-02-21 07:41发布

问题:

Cropped characters - iOS11 - Alert Dialog. How to fix it?

[


func settingsButtonPressed() {
    let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
    let closeAction = UIAlertAction(title: "Anuluj", style: .cancel) { (action) in
        //do nothing
    }
    alert.addAction(closeAction)
    let restorePurchases = UIAlertAction(title: "Przywróć zakupy", style: .default) { (action) in
        self.restorePurchases()
    }
    alert.addAction(restorePurchases)

    let refreshCatalogs = UIAlertAction(title: "Odśwież", style: .default) { (action) in
        self.collectionView.reloadData()
    }
    alert.addAction(refreshCatalogs)
    let delPubs = UIAlertAction(title: "Usuń publikacje", style: .destructive) { (action) in
        self.deletePublications()
    }
    alert.addAction(delPubs)
    present(alert, animated: true, completion: nil)
}

回答1:

Try to use NSLocalizedString instead of hardcoded values. Usage article here.

Then just define your titles like that:

let cancelButtonText = NSLocalizedString("Cancel", comment: "")

And set it:

let cancelAction = UIAlertAction(title: cancelButtonText, style: .cancel, handler: nil)