【发布时间】:2020-10-08 18:23:58
【问题描述】:
Xcode 12.0.1
我正在尝试使用情节提要删除 UIButton 上的标题标签文本。然后我计划以编程方式设置它。通过情节提要删除文本时,预览会显示已删除的文本。但是,当我构建和运行应用程序时,文本仍然存在。
以编程方式更改也不起作用。我尝试在控制器中更改 viewDidLoad()
punchBtn.setTitle("Transfer", for: .normal)
punchBtn.setTitle("Transfer", for: .application)
punchBtn.setTitle("Transfer", for: .selected)
punchBtn.setTitle("Transfer", for: .reserved)
punchBtn.setTitle("Transfer", for: .highlighted)
punchBtn.setTitle("Transfer", for: .disabled)
punchBtn.setTitle("Transfer", for: .focused)
有趣的是,当按钮被选中时,文本会发生变化:
任何建议将不胜感激。
【问题讨论】:
-
您应该对“punch”进行全文搜索。可能有一些重复的按钮,或者您在删除文本后没有按 Enter 键。
-
试试我的答案,这对我有用
标签: ios xcode swift4 xcode-storyboard