小编use*_*509的帖子

如何获取在UIAlertController Swift的Alert中选择的项目的索引

我将使用UIAlertController为用户选择一个项目.要选择的项目如下:

let arraySelect = ["NewYork", "Washington", "Seoul", "Tokyo", "Peking", "Sidney", ... ]

   let alert = UIAlertController(title: nil, message: nil, preferredStyle: .Alert)

        // Add items in array to Alert
        for var i = 0; i < arraySelect.count; i++ {
            alert.addAction(UIAlertAction(title: arrayBibleVersions[i], style: .Default, handler: {(_) in }))
        }

        // Add cancel button.    
        alert.addAction(UIAlertAction(title: "??", style: .Cancel, handler: {(_) in }))

        self.presentViewController(alert, animated: false, completion: nil)
Run Code Online (Sandbox Code Playgroud)

当用户触摸一个项目时,我必须获取用户触摸的项目的索引.但我不知道如何获得索引..请帮帮我.

indexing swift uialertcontroller

2
推荐指数
1
解决办法
4480
查看次数

标签 统计

indexing ×1

swift ×1

uialertcontroller ×1