2013-10-23 2 views
1

로그인 버튼과 가입 버튼을 호스팅하는 앱이 있습니다. 인터넷에 연결할 수없는 경우 reachability를 사용하여 해당 버튼을 숨김으로 표시합니다. 이 작업이 완료되면 내가, 내가 alertview을이보기의 알파와 함께 연주 몇 가지 간단한 애니메이션을 원하는가 이제보기UIView, animate, completionblock, UIAlertView

self.coveringview 

을 포함하는이 코드에 일어날 어떤 사용자에게 팝업을 내가 뭐하는 거지 볼 수 있습니다 그것은 alert.with를 완료하여 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; 
        }]; 
} 

답변

1

은 '아무튼 그래서 그들은 모두보기를 만들 것입니다 당신은 setHidden 0.0의 알파 모두를 사용할 필요가 없습니다 귀하의 인터페이스 빌더에서 self.coveringView.hidden = YES를 제거하고 단지 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; 
         } 
        }]; 
+0

여전히 그 일을하지, 그것은 너무 빨리, 내가 여기 아마 멀티 스레딩에 문제가 있다고 생각 팝업 ?? – Eddie

+0

나는 그런 식으로 시도한 대답을 편집했습니다. –

+0

아직도 그것을하고 있지 않습니다. 나는 또 다른 지연이 필요하다고 생각합니다. – Eddie

0

설정 t는 닿는다. 숨겨진/알아볼 수없는 부분이 알파 변경과 충돌 할 가능성이 큽니다. 다음과 같이 단순화

시도 :

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) { 
        }]; 
} 
+0

안녕하세요, 이것은 다른 주제를 단순화 한 것이지만 원래의 문제를 해결하지 못하더라도 경고가 갑자기 나타납니다. – Eddie