search

Home  >  Q&A  >  body text

ios - button状态改变问题

button原始selected为no,前面判断语句也显示其为no,当点击这个按钮的时候,self.btn.selected = !=self.btn,selected,再次判断判断这个btn还是no,再点一次才为selected,变为normal也要点两次,什么原因,大神求解

PHPzPHPz2894 days ago586

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:52:24

    Isn’t it supposed to be like this
    self.btn.selected = !self.btn.selected;

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:52:24

    First, you set different colors for the two states of the button, and execute the following sentence in the click event of the button. If the colors change each other, there will be no problem.

    self.btn.selected = !self.btn.selected;

    reply
    0
  • Cancelreply