2013-12-16 3 views
0

I는 버튼 보여주는 키보드에 응답하여 다른 뷰를 이동 애니메이션 코드를 가지고UIAlertView 블록 기반 애니메이션

NSValue *frameValue = [note userInfo][UIKeyboardFrameEndUserInfoKey]; 
CGRect keyboardFrame = [frameValue CGRectValue]; 
CGFloat keyboardHeight = keyboardFrame.size.height*kCGPKeyboardAnimationTranslationAdjustmentFactor; 
CGFloat animationDuration = [[note userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue]; 
UIViewAnimationOptions animationCurveOption = [[note userInfo][UIKeyboardAnimationCurveUserInfoKey] integerValue] >> 16; 

CGPoint submitButtonCenter = [[self submitButton] center]; 
CGPoint offsetSubmitButtonCenter = CGPointMake(submitButtonCenter.x, submitButtonCenter.y-keyboardHeight); 

__block __weak __typeof(self) wSelf = self; 
NSCParameterAssert([wSelf isKindOfClass:[self class]]); 
[UIView animateWithDuration:animationDuration delay:0.0f options:animationCurveOption animations:^{ 

    [[wSelf submitButton] setCenter:offsetSubmitButtonCenter]; 

} completion:nil 
    }]; 

I는 UIAlertView

를 표시 할 때이 애니메이션 나중에 취소 도착
- (void)displayError:(NSError*)error { 
    NSCParameterAssert([NSThread isMainThread]); 
    NSString *errorDescription = [error description]; 
    UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"" message:errorDescription delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    NSLog(@"%s: Recursive View Description: %@",__PRETTY_FUNCTION__,[[[self view] subviews] description]); 
    [av show]; 
    NSLog(@"Is it still there? %s Recursive View Description: %@",__PRETTY_FUNCTION__,[[[self view] subviews] description]); 
} 

버튼 프레임은 [av show]이 호출 된 직후 변경되어 애니메이션 이전의 정확한 위치로 되돌립니다. [av show]을 주석 처리하면 버그가 사라지므로 부작용처럼 보입니다.

해당 코드는 없지만 같은 방식으로 이동 한 다른 여러 UIView 및 UITextField 개체가 있습니다. 그들은 영향을받지 않으며 UIButton 만 움직입니다.

누구나 수정 방법에 대한 아이디어가 있습니까?

+0

음, 문제는 당신이 옵션으로 애니메이션 커브를 사용하고 있다는 것입니다. 여기서이 방법으로 사용하면 안됩니다. 문제의 원인이되는 옵션 중 하나 일 수 있습니다. –

+0

@LeoNatan이 애니메이션 옵션 인수를 'UIViewAnimationOptionCurveLinear'로 변경해도 버그가 사라지지 않습니다. –

답변

0

몇 시간 동안 디버깅을하고 근본 원인을 파악한 후 대답은 간단했습니다.

제출 버튼을 이전 위치로 되돌려 놓은 것인데 자동 레이아웃이 트리거 된 UIAlertView을 닫습니다. 구속을 설정하거나 자동 레이아웃을 끄고 자동 크기 조정 마스크를 사용하여 문제가 해결되었습니다.

관련 문제