我将使用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)
当用户触摸一个项目时,我必须获取用户触摸的项目的索引.但我不知道如何获得索引..请帮帮我.