在IOS中用户隐藏预测时获取通知

时间:2014-12-30 09:13:13

标签: ios

主题:

对于ios 8我需要一些通知,如果我通过向下滑动预测视图来隐藏单词预测 我需要通知预测ON / OFF.can你有什么想法吗?

我的尝试:

我为了分离ios 7/8而上下框架。但是当我通过向下滑动预测视图隐藏预测词时,我的文本视图仍然在向上框架中它确实已经下降..

这是我的代码

if([[[UIDevice currentDevice]systemVersion] floatValue]>=8.0f)
{

    ChatViewBottomTool.frame = CGRectMake(screenArea.origin.x, screenArea.size.height-310, screenArea.size.width,44);
    ChatViewTable.frame = CGRectMake(ChatViewTable.frame.origin.x, ChatViewTable.frame.origin.y, screenArea.size.width,  screenArea.size.height-372);
    [ChatViewBottomTool sizeToFit];

    }else{

    ChatViewBottomTool.frame = CGRectMake(screenArea.origin.x, screenArea.size.height-280, screenArea.size.width,44);
    ChatViewTable.frame = CGRectMake(ChatViewTable.frame.origin.x, ChatViewTable.frame.origin.y, screenArea.size.width,  screenArea.size.height-342);
    [ChatViewBottomTool sizeToFit];
 }

1 个答案:

答案 0 :(得分:0)

您可以使用UIKeyboardWillShowNotification来获得正确的键盘框架:

- (void)viewDidLoad
{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)  name:UIKeyboardWillShowNotification  object:self.view.window];
}

- (void)keyboardWillShow:(NSNotification *)notification
{
    CGRect keyboardFrame = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    double duration = [[notification.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];

    [UIView animateWithDuration:duration animations:^{
            // Do something with keyboard frame with same animation duration
    }];
}