UIAlertView按钮文本更改

时间:2015-02-26 14:11:04

标签: swift button uialertview rename

从侧边菜单中选择行后,我使用以下代码调用alertView(对于iOS7):

var choiceAlert: UIAlertView = UIAlertView()
choiceAlert.title = "Direction"
choiceAlert.message = "Select a direction for no. \(lineNmb)."
choiceAlert.addButtonWithTitle(dirA)
choiceAlert.addButtonWithTitle(dirB)
choiceAlert.addButtonWithTitle("Cancel")
choiceAlert.delegate = self
choiceAlert.tag = 3
choiceAlert.show()

当我第一次调用它时,一切正常(它显示为我想要它),但是当我从侧面菜单中选择新行时,lineNmb被更改,但按钮文本保持不变第一次打电话。

例如,第一次显示:

First atempt

然后对于新选择我得到了这个(按钮保持同名):

Second atempt

我应该有这个(iOS8和UIAlertController的例子,一切都很好):

Shoud be

如果我将println(dirA)放在choiceAlert.addButtonWithTitle(dirA)的前面,我可以看到dirA的值已更改,变量获取新文本,但{{1}内部未更改}}。有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

我已通过以这种方式调用UIAlertView来解决此问题:

var choiceAlert = UIAlertView(title: "Direction", message: "Select a direction for no. \(lineNmb).", delegate: nil, cancelButtonTitle: "Cancel", otherButtonTitles: dirA,dirB)
choiceAlert.delegate = self
choiceAlert.tag = 3
choiceAlert.show()
相关问题