У меня есть список стран, которые я хочу показать, используя UIAlertController
. Это действительно появляется, но это занимает слишком много времени, так как существует более 150 стран.
Так как я могу ускорить этот процесс, используя только UIAlertController
.
Вот мой код:
let alert = UIAlertController(title: "", message: "Select country", preferredStyle: UIAlertController.Style.alert)
let cancel1 = UIAlertAction.init(title: "Cancel", style: .destructive, handler: nil)
alert.addAction(cancel1)
for dict in self.aCountry{
let tempDict:[String:Any] = dict as! [String:Any]
let action = UIAlertAction.init(title: tempDict["country_name"] as? String, style: .default) { (completed) in
self.tfCountry.text = tempDict["country_name"] as? String
}
alert.addAction(action)
}
let cancel2 = UIAlertAction.init(title: "Cancel", style: .destructive, handler: nil)
alert.addAction(cancel2)
self.present(alert, animated: true, completion: nil)
Ps - aCountry
- массив странимена