工程中需要需要实现自定义的弹出提示框,暂时的实现方法是alloc一个view出来,以subView的方式加在底部的webView上面正中间,这样在keyboard弹出时,提示框被遮住,需要修改。

既然是keyBoard引起的问题,那我们就获取keyBoard弹出的状态,如果是弹出状态,那么调整位置,使提示框能正常显示。

我们在ViewDidLoad里添加下面俩个方法:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillhide:) name:UIKeyboardWillHideNotification object:nil];

addObserver:注册一个观察员name:消息名称

以上步骤完成后,在键盘弹出时,系统监听到,就会调用:

- (void)keyboardWillShow:(NSNotification *)notification;

在键盘隐藏后,会调用:

- (void)keyboardWillhide:(NSNotification *)notification;

我们还可以通过notification获取键盘的相关信息(高度,类型等)。

posted on 2013-07-08 20:12  nanoCramer  阅读(1181)  评论(0编辑  收藏  举报