0

. 왜 그 이유를 이해할 수 있습니까?고르지 애니메이션 : alertView에서 : didDismissWithButtonIndex : 그것은 고르지이고 (엑스 코드 7.3.1을 사용하여) 빨리 <code>alertView:didDismissWithButtonIndex:</code> 그것이 <code>UIalertView</code> 대리자 메서드 내부 끝나면 나는 방법 <code>popViewControllerAnimated:</code>의 애니메이션 문제가있어

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex != alertView.cancelButtonIndex) 
    { 
     // code is running om main thread 
     if ([[NSThread currentThread]isMainThread]) { 
      // still - by using GCD and go to main thread, the animation works!! 
      dispatch_async(dispatch_get_main_queue(), ^{ 
       [self.navigationController popViewControllerAnimated:YES]; 
      }); 
     } 
    } 
} 

그리고이 :

나는 UIAlertView 잠시 동안 사용되지 않습니다 것을 알고
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 

    if(buttonIndex != alertView.cancelButtonIndex) 
    { 
     // no problem with animation when done in alertView:clickedButtonAtIndex: 
     [self.navigationController popViewControllerAnimated:YES]; 
    } 
} 

, 그것은 할 수있다

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex != alertView.cancelButtonIndex) 
    { 
     // animation of popViewControllerAnimated: is not working correctly 
     [self.navigationController popViewControllerAnimated:YES]; 
    } 
} 

이상한 것은이 코드는 문제없이 작동한다는 것입니다 그것 덕분에? 이 코드는 2012 년부터 앱에서 손대지 않았으며 최근에 이상하게 행동하기 시작했습니다. I로`:

답변

1

당신이 willDismissWithButtonIndex 대신 나를 위해

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex != alertView.cancelButtonIndex) 
    { 
     [self.navigationController popViewControllerAnimated:YES]; 
    } 
} 

didDismissWithButtonIndex의이 작품 확인에 시도 할 수 있습니다! I이, 예를 작동 감사 :)뿐만 아니라`clickedButtonAtIndex을

+0

도움이되기를 바랍니다 질문에 썼다. 그러나 나는'didDismissWithButtonIndex : '의 문제점에 대해 여전히 의문 스럽다. – turingtested