是否有可能在iOS 8中找到UITextField的自动更正文本处于OPEN / CLOSE状态?

时间:2014-10-09 11:55:49

标签: objective-c uitextfield ios8

我正在启用UITextField的自动更正选项以显示建议文本。这里我的问题是要确定建议文本视图处于OPEN状态或CLOSE状态。

enter image description here

enter image description here

请任何人给我一个关于此的想法。

1 个答案:

答案 0 :(得分:0)

我们可以使用键盘高度变化通知检测此更改,如下所示,

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(didReceiveKeyboardWillChangeFrameNotification:)
                                                 name:UIKeyboardWillChangeFrameNotification
                                               object:nil];


- (void)didReceiveKeyboardWillChangeFrameNotification:(NSNotification *)notification
{

        NSDictionary *userInfo = [notification userInfo];

        CGRect keyboardEndFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

        if (CGRectIsNull(keyboardEndFrame)) {
            return;
        }

        UIViewAnimationCurve animationCurve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
        NSInteger animationCurveOption = (animationCurve << 16);

        double animationDuration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];

        [UIView animateWithDuration:animationDuration
                              delay:0.0
                            options:animationCurveOption
                         animations:^{


                         }
                         completion:^(BOOL finished) {


                         }];
}