if语句永远不会被animateWIthDuration函数中给出的值所满足

时间:2017-08-24 17:10:26

标签: ios objective-c

预期的行为应该是在数组位置4上满足if语句,使我的按钮弹出的功能起作用。但是,他们永远不会弹出。我已将NSLog功能放在两个区域中,第一个区域报告值为1,但第二个区域从未报告值?有什么帮助吗?

//Message 1
_introDialogue.text = messageArray[0];
[UIView animateWithDuration:2
                      delay:1.5
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^
 {
     [_introDialogue setAlpha:1];
 }
                 completion:^(BOOL finished)
 {
     [UIView animateWithDuration:2
                           delay:1
                         options:UIViewAnimationOptionCurveEaseInOut
                      animations:^
      {
          [_introDialogue setAlpha:0];
      }
                      completion:^(BOOL finished)
      {
          //Message 2
          _introDialogue.text = messageArray[1];
          [UIView animateWithDuration:2
                                delay:0.2
                              options:UIViewAnimationOptionCurveEaseIn
                           animations:^
           {
               [_introDialogue setAlpha:1];
           }
                           completion:^(BOOL finished)
           {
               [UIView animateWithDuration:2
                                     delay:3
                                   options:UIViewAnimationOptionCurveEaseInOut
                                animations:^
                {
                    [_introDialogue setAlpha:0];
                }
                                completion:^(BOOL finished)
                {
                    //Message 3
                    _introDialogue.text = messageArray[2];
                    [UIView animateWithDuration:2
                                          delay:0.2
                                        options:UIViewAnimationOptionCurveEaseIn
                                     animations:^
                     {
                         [_introDialogue setAlpha:1];
                     }
                                     completion:^(BOOL finished)
                     {
                         [UIView animateWithDuration:2
                                               delay:2.5
                                             options:UIViewAnimationOptionCurveEaseInOut
                                          animations:^
                          {
                              [_introDialogue setAlpha:0];
                          }
                                          completion:^(BOOL finished)
                          {
                              //Message 4
                              _introDialogue.text = messageArray[3];
                              [UIView animateWithDuration:2
                                                    delay:0.2
                                                  options:UIViewAnimationOptionCurveEaseIn
                                               animations:^
                               {
                                   [_introDialogue setAlpha:1];
                               }
                                               completion:^(BOOL finished)
                               {
                                   [UIView animateWithDuration:2
                                                         delay:2.5
                                                       options:UIViewAnimationOptionCurveEaseInOut
                                                    animations:^
                                    {
                                        [_introDialogue setAlpha:0];
                                    }
                                                    completion:^(BOOL finished)
                                    {
                                        //Message 5
                                        _isGTG = 1;
                                        NSLog(@"%d", _isGTG);
                                        _introDialogue.text = messageArray[4];

                                        [UIView animateWithDuration:2
                                                              delay:0.2
                                                            options:UIViewAnimationOptionCurveEaseIn
                                                         animations:^
                                         {
                                             [_introDialogue setAlpha:1];
                                         }
                                                         completion:^(BOOL finished)
                                         {
                                             [UIView animateWithDuration:2
                                                                   delay:5
                                                                 options:UIViewAnimationOptionCurveEaseInOut
                                                              animations:^
                                              {
                                                  [_introDialogue setAlpha:0];
                                              }
                                                              completion:^(BOOL finished)
                                              {
                                                  //Message 6
                                                  _introDialogue.text = messageArray[5];
                                                  [UIView animateWithDuration:2
                                                                        delay:0.2
                                                                      options:UIViewAnimationOptionCurveEaseIn
                                                                   animations:^
                                                   {
                                                       [_introDialogue setAlpha:1];
                                                   }
                                                                   completion:^(BOOL finished)
                                                   {
                                                       [UIView animateWithDuration:2
                                                                             delay:2
                                                                           options:UIViewAnimationOptionCurveEaseInOut
                                                                        animations:^
                                                        {
                                                            [_introDialogue setAlpha:0];
                                                        }
                                                                        completion:^(BOOL finished)
                                                        {

                                                        }
                                                        ];
                                                   }
                                                   ];
                                              }
                                              ];
                                         }
                                         ];
                                    }
                                    ];
                               }
                               ];
                          }
                          ];
                     }
                     ];
                }
                ];
           }
           ];
      }
      ];
 }
];

NSLog(@"%d", _isGTG);

//Button pop w/ spring effect animation
if (_isGTG == 1)
{
    [UIView animateWithDuration:1
                          delay:0.8
         usingSpringWithDamping:0.45
          initialSpringVelocity:0.02
                        options:UIViewAnimationOptionCurveLinear
                     animations:^
                     {
                         _orText.text = @"or";

                         [UIView animateWithDuration:2
                                          animations:^
                                          {
                                              [_orText setAlpha:1];
                                          }
                          ];
                         [UIView animateWithDuration:0.6
                                          animations:^
                                          {
                                              _emailLoginForwardButton.frame = CGRectMake(77, 470, 40, 40);
                                          }
                         ];
                         [UIView animateWithDuration:0.6
                                               delay:0.4
                                             options:UIViewAnimationOptionCurveLinear
                                          animations:^
                                          {
                                              _googleLoginForwardButton.frame = CGRectMake(257, 470, 40, 40);
                                          }
                                          completion:^(BOOL finished)
                                          {
                                          }
                          ];
                     }
                     completion:^(BOOL finished)
                     {
                     }
     ];
}
else
{
}

}

1 个答案:

答案 0 :(得分:0)

在_isGTG设置为1之前调用第二个日志NSLog(@"%d", _isGTG);

所以当你达到这个条件并打印时,在_isGTG设置为1之前执行此操作之前没有任何值会尝试再次安排这部分代码