Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UIKeyboardWillShowNotification不调用,只有UIKeyboardWillHideNotification在iOS 9中调用_Objective C_Iphone_Notifications_Uitextfield_Ios9 - Fatal编程技术网

Objective c UIKeyboardWillShowNotification不调用,只有UIKeyboardWillHideNotification在iOS 9中调用

Objective c UIKeyboardWillShowNotification不调用,只有UIKeyboardWillHideNotification在iOS 9中调用,objective-c,iphone,notifications,uitextfield,ios9,Objective C,Iphone,Notifications,Uitextfield,Ios9,在iOS 8之前一切正常。 但当用户点击文本字段时,控件直接进入UIKeyboardWillHideNotification通知 登录控制台-找不到支持键盘iPhoneTruffle NumberPad类型4的键盘平面;使用675849259_Turfle_iPhone-Simple-Pad_默认值 这是代码-- 这可能与模拟器设置有关,请参阅菜单“硬件>键盘>连接键盘硬件”。如果此选项处于启用状态,您将获得UIKeyboardWillHideNotification,但决不会UIKeyboar

在iOS 8之前一切正常。 但当用户点击文本字段时,控件直接进入UIKeyboardWillHideNotification通知 登录控制台-找不到支持键盘iPhoneTruffle NumberPad类型4的键盘平面;使用675849259_Turfle_iPhone-Simple-Pad_默认值

这是代码--


这可能与模拟器设置有关,请参阅菜单“硬件>键盘>连接键盘硬件”。如果此选项处于启用状态,您将获得
UIKeyboardWillHideNotification
,但决不会
UIKeyboardWillShowNotification

这是模拟的问题,也会有类似的问题。您的代码是否只在真实设备上工作?
`
In view did load
- (void)viewDidLoad {
    [super viewDidLoad];
    self.txtMobNumber.delegate = self;
    self.txtMobNumber.keyboardType = UIKeyboardTypeNumberPad;

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

notification callback
- (void)keyboardWillShow:(NSNotification *)notification
{
    // Save the height of keyboard and animation duration
    NSDictionary *userInfo = [notification userInfo];
    CGRect keyboardRect = [userInfo[@"UIKeyboardBoundsUserInfoKey"] CGRectValue];
    [UIView beginAnimations:@"moveKeyboard" context:nil];
    float height = keyboardRect.size.height-60;
    self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y - height, self.view.frame.size.width, self.view.frame.size.height);
    [UIView commitAnimations];
    //  [self setNeedsUpdateConstraints];
}
// Reset the desired height
- (void)keyboardWillHide:(NSNotification *)notification
{
    // Reset the desired height (keep the duration)
    NSDictionary *userInfo = [notification userInfo];
    CGRect keyboardRect = [userInfo[@"UIKeyboardBoundsUserInfoKey"] CGRectValue];
    [UIView beginAnimations:@"moveKeyboard" context:nil];
    float height = keyboardRect.size.height-60;
    self.view.frame = CGRectMake(self.view.frame.origin.x,         self.view.frame.origin.y + height, self.view.frame.size.width, self.view.frame.size.height);
    [UIView commitAnimations];

}

`