1

サインイン ボタンとサインアップ ボタンをホストするログイン画面を備えたアプリがあり、インターネットに接続できないことを検出した場合は到達可能性を使用して、カバー ビューを表示してこれらのボタンを非表示にします

 self.coveringview

ここで、このビューのアルファで再生する簡単なアニメーションを実行します。それが完了したら、alertview をポップアップしてユーザーに何が起こるかを伝えたいと思います。このコードでは、alert.show をanimatewithduration の完了ブロック。

bahvior は私が望むものではありません。表示したいフェードアウトをユーザーに表示せずにアラートがあまりにも速くポップアップします。どうすればよいですか?

NetworkStatus netStatus = [reachability currentReachabilityStatus];
if(netStatus == NotReachable) {
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection"
                                                  message:@"Unable to connect to the server.  
     Please check your internet connection and try again."
                                                 delegate:self
                                        cancelButtonTitle:nil
                                        otherButtonTitles:@"OK", nil];
  [UIView animateWithDuration:1.0
                         animations:^{
                                self.coveringView.alpha = 1.0;
                         }completion:^(BOOL finished) {
                             // this is the problem here, I need to make this alert show up after  
                             the fade out occurs completely
                             [alert show];
                             self.coveringView.hidden = NO;
                         }];
}
else {
  [UIView animateWithDuration:1.0
                   animations:^{
                      self.coveringView.alpha = 0.0;
                   }completion:^(BOOL finished) {
                      self.coveringView.hidden = YES;
                   }];
}
4

2 に答える 2

1

self.coveringView.hidden = YESあなたの Interface Builder からあなたを削除し、ちょうど設定しますalpha = 0

NetworkStatus netStatus = [reachability currentReachabilityStatus];
if(netStatus == NotReachable) {
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection"
                                                  message:@"Unable to connect to the server.  
     Please check your internet connection and try again."
                                                 delegate:self
                                        cancelButtonTitle:nil
                                        otherButtonTitles:@"OK", nil];

    [UIView animateWithDuration:1.0
                     animations:^{
                            self.coveringView.alpha = 1.0;
                     }completion:^(BOOL finished) {
                         // this is the problem here, I need to make this alert show up after  the fade out occurs completely
                      if(finished){
                         [alert show];
                      }
                     }];                     



}
else {
  [UIView animateWithDuration:1.0
                   animations:^{
                      self.coveringView.alpha = 0.0;
                   }completion:^(BOOL finished) {
                      if(finished){
                      self.coveringView.hidden = YES;
                      }
                   }];
于 2013-10-23T00:48:55.577 に答える
0

setHidden と 0.0 のアルファの両方を使用する必要はありません。両方とも、タッチをインターセプトしないようにビューを作成します。hidden/notHidden がアルファの変更と競合している可能性があります。

次のように単純化してみてください。

NetworkStatus netStatus = [reachability currentReachabilityStatus];
if(netStatus == NotReachable) {
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection"
                                                  message:@"Unable to connect to the server.  
     Please check your internet connection and try again."
                                                 delegate:self
                                        cancelButtonTitle:nil
                                        otherButtonTitles:@"OK", nil];
  [UIView animateWithDuration:1.0
                         animations:^{
                                self.coveringView.alpha = 1.0;
                         }completion:^(BOOL finished) {
                             //I need to make this alert show up after the fade out occurs completely
                             [alert show];
                         }];
}
else {
  [UIView animateWithDuration:1.0
                   animations:^{
                      self.coveringView.alpha = 0.0;
                   }completion:^(BOOL finished) {
                   }];
}
于 2013-10-23T01:40:07.950 に答える