iOS - 如何将字符串设置为按钮的标题

时间:2013-11-18 08:59:41

标签: ios variables

我正在Xcode中创建一个应用程序,我希望将变量“selectedAnswer”设置为我的按钮answer1的标题/文本。 answer1是IBOutlet和IBAction。

3 个答案:

答案 0 :(得分:1)

[answer1 setTitle:selectedAnswer forState:UIControlStateNormal];

答案 1 :(得分:1)

尝试以下

  NSString *selectedAnswer = @"Title";
  [answer1 setTitle: selectedAnswer forState: UIControlStateNormal];

答案 2 :(得分:0)

编写此代码:

 [answer1 setTitle:selectedAnswer forState:UIControlStateNormal];