문제

i 키보드 위에 맞춤 포커스 바를 구현하고 있습니다.포커스 바에는 커서를 다시 이동하고 완료 버튼과 함께 앞으로 이동하는 위젯이 있습니다.

이제 iOS 7을 사용하면 초점 바가 키보드보다 빠르게 움직이고 있습니다.두 번째로 인해 키보드 맨 위에 앉아 있기 전에 초점 막대 뒤에 화면이 표시됩니다.이것은 iOS 6에서 잘 작동합니다.

아래는 제가 수행하고있는 것입니다 :

- (void)keyboardWillShow:(NSNotification *)iNotification {
    self.dismissForm = NO;
    self.shouldScrollCell = YES;
    CGFloat aKeyboardAnimationDuration = [[iNotification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    CGRect aKeyboardFrame = [[iNotification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue];
    CGRect adjustedKeyboardFrame = [self.view convertRect:aKeyboardFrame fromView:nil];
    CGFloat adjustedHeight;
    adjustedHeight = aKeyboardFrame.size.height + self.focusControlBar.frame.size.height;
    [self.focusControlBar viewForFocusControlWillShowWithEndFrame:adjustedKeyboardFrame andAnimationDuration:aKeyboardAnimationDuration];

    [UIView animateWithDuration:0.3 animations:^() {
        [self.tableView setContentInset:UIEdgeInsetsMake(kScreenOrigin, kScreenOrigin, adjustedHeight, 0.0f)];
        [self.tableView setScrollIndicatorInsets:UIEdgeInsetsMake(kScreenOrigin, kScreenOrigin, adjustedHeight, 0.0f)];
    }];
}
.

이것은 내 초점 바입니다. 애니메이션 코드 :

- (void)viewForFocusControlWillShowWithEndFrame:(CGRect)iFrame andAnimationDuration:(CGFloat)iDuration {
    BOOL aShouldAppear = YES;   

    if (self.delegate && [self.delegate respondsToSelector:@selector(focusControlBarShouldAppear:)]) {
        aShouldAppear = [self.delegate focusControlBarShouldAppear:self];
    }

    if (aShouldAppear) {
        if (self.delegate && [self.delegate respondsToSelector:@selector(focusControlBarWillAppear:)]) {
            [self.delegate focusControlBarWillAppear:self];
        }
        CGRect aBarFrame = self.frame;
        UIInterfaceOrientation anInterfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
        aBarFrame.size.height = [self heightForOrientation:anInterfaceOrientation];
        self.frame = aBarFrame;
        aBarFrame.origin.y = self.superview.bounds.size.height - iFrame.size.height - aBarFrame.size.height;


        [UIView animateWithDuration:iDuration animations:^(void) {
            self.frame = aBarFrame;
        } completion:^(BOOL iFinished) {
            if (self.delegate && [self.delegate respondsToSelector:@selector(focusControlBarDidAppear:)]) {
                [self.delegate focusControlBarDidAppear:self];
            }
        }];
    }
}
.

도움이 되었습니까?

해결책

IOS 7을 사용하여 KeyboardAnimationCurve를 고려해야합니다.아래의 수정 된 코드와 함께 작동했습니다.

- (void)keyboardWillShow:(NSNotification *)iNotification {
    self.dismissForm = NO;
    self.shouldScrollCell = YES;

    NSDictionary *aNotificationInfo = [iNotification userInfo];
    CGFloat aKeyboardAnimationDuration = [aNotificationInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    UIViewAnimationCurve aKeyboardAnimationCurve = [aNotificationInfo[UIKeyboardAnimationCurveUserInfoKey] intValue];
    CGRect aKeyboardFrame = [aNotificationInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
    CGRect adjustedKeyboardFrame = [self.view convertRect:aKeyboardFrame fromView:nil];
    CGFloat adjustedHeight;
    adjustedHeight = aKeyboardFrame.size.height + self.focusControlBar.frame.size.height;

    [self.focusControlBar viewForFocusControlWillShowWithEndFrame:adjustedKeyboardFrame animationCurve:aKeyboardAnimationCurve andAnimationDuration:aKeyboardAnimationDuration];

    [UIView animateWithDuration:0.3 animations:^() {
        [self.tableView setContentInset:UIEdgeInsetsMake(kScreenOrigin, kScreenOrigin, adjustedHeight, 0.0f)];
        [self.tableView setScrollIndicatorInsets:UIEdgeInsetsMake(kScreenOrigin, kScreenOrigin, adjustedHeight, 0.0f)];
    }];
}

- (void)viewForFocusControlWillShowWithEndFrame:(CGRect)iFrame animationCurve:(UIViewAnimationCurve)iAnimationCurve andAnimationDuration:(CGFloat)iDuration {
    BOOL aShouldAppear = YES;   

    if (self.delegate && [self.delegate respondsToSelector:@selector(focusControlBarShouldAppear:)]) {
        aShouldAppear = [self.delegate focusControlBarShouldAppear:self];
    }

    if (aShouldAppear) {
        if (self.delegate && [self.delegate respondsToSelector:@selector(focusControlBarWillAppear:)]) {
            [self.delegate focusControlBarWillAppear:self];
        }

        CGRect aBarFrame = self.frame;
        UIInterfaceOrientation anInterfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
        aBarFrame.size.height = [self heightForOrientation:anInterfaceOrientation];
        self.frame = aBarFrame;
        aBarFrame.origin.y = self.superview.bounds.size.height - iFrame.size.height - aBarFrame.size.height;

        [UIView animateWithDuration:iDuration delay:0.0 options:(iAnimationCurve << 16) animations:^{
            self.frame = aBarFrame;
        } completion:^(BOOL finished) {
            if (self.delegate && [self.delegate respondsToSelector:@selector(focusControlBarDidAppear:)]) {
                [self.delegate focusControlBarDidAppear:self];
            }
        }];
    }
}
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top