search

Home  >  Q&A  >  body text

ios - 求 oc goto语句的正确姿势,现在goto 的调用在条件以内,但是实际情况是条件没满足也调用了,什么情况?谢谢

求 oc goto语句的正确姿势,现在goto 的调用在条件以内,但是实际情况是条件没满足也调用了,什么情况?谢谢

天蓬老师天蓬老师2771 days ago1027

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-04-18 09:42:15

    Follow the normal program execution sequence, after self.collectionView.alpha = 1, continue to execute the following code. goto just helps you jump to this sentence in advance, it does not mean that when the normal sequence execution reaches this point, the execution of the code included in this goto will be skipped.
    It can be roughly understood that if there is no break in the switch, the following code will continue to be executed.

    If it were me, I would write it as

    if(pangestureRecongnizer.state == UIGestureRecognizerStateEnded && offsetY<=70 && offsetY >= -70 ){

    self.collectionView.alpha = 1;

    }else{

    collectionViewHidden

    }

    reply
    0
  • Cancelreply