键盘通知未在设备上触发

时间:2012-12-03 01:20:30

标签: ios ipad ios6

在模拟器上运行时没有问题,但通知未在设备上发布(iPad 3和Mini都运行iOS 6)。如果我自己发布通知,则会调用处理程序。我想知道你们中是否有人碰到这个并且有任何想法。

以下是设置处理程序的代码:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iPadEditSetTitleHandleKeyboardDidShowNotification:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iPadEditSetTitleHandleKeyboardWillShowNotification:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iPadEditSetTitleHandleKeyboardWillHideNotification:) name:UIKeyboardWillHideNotification object:nil];

处理程序本身的定义:

- (void)iPadEditSetTitleHandleKeyboardWillHideNotification:(NSNotification *)notification
- (void)iPadEditSetTitleHandleKeyboardWillShowNotification:(NSNotification *)notification
- (void)iPadEditSetTitleHandleKeyboardDidShowNotification:(NSNotification *)notification

感谢任何帮助。

更新:

开始一个新项目,让所有的东西都在视线控制器之外。

//
//  DWViewController.m
//  KeyboatdTest
//
//  Created by Dan Wesnor on 12/3/12.
//  Copyright (c) 2012 Dan Wesnor. All rights reserved.
//

#import "DWViewController.h"

@interface DWViewController ()

@end

@implementation DWViewController


- (void)handleKeyboardNotification:(NSNotification *)notification
{
    NSLog(@"%@", notification.name);
}



- (void)viewDidLoad
{
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardNotification:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardNotification:) name:UIKeyboardWillHideNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardNotification:) name:UIKeyboardDidShowNotification object:nil];
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end

故事板包含单个文本字段。其他一切都是标准的单视图应用模板。

仍然没有快乐。在模拟器中应该工作,但不能在iPad本身上工作。它可能与配置或代码本身之外的某些事情有关吗?

1 个答案:

答案 0 :(得分:5)

这是一个很好的无证件行为。

分割键盘时不会触发这3个通知。但是,看起来在它们通常会触发之前附加UITextField.inputAccessoryView,即使键盘被分割,它们也会触发。因此,在收到UIKeyboardWillChangeFrameNotification后附加附件视图,其他三个将正常激活。