0

There is no problem when running on the simulator, but the notifications are not posting on the devices (iPad 3 and Mini both running iOS 6). If I post the notification myself, the handler gets called. I was wondering if any of you guys have run into this and have any ideas.

Here is the code setting up the handlers:

[[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];

And the definitions of the handlers themselves:

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

Any help is appreciated.

UPDATE:

Started a new project to get everything out of the way here is the view controller, all of it.

//
//  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

The storyboard contains a single text field. Everything else is the standard single-view app template.

Still no joy. Works as it should in the simulator, but not on the iPad itself. Could it be something to do with provisioning or something outside of the code itself?

4

1 回答 1

5

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

拆分键盘时不会触发这 3 个通知。但是,似乎在它们通常会触发之前附加 UITextField.inputAccessoryView ,即使键盘被拆分,它们也会触发。所以在收到 UIKeyboardWillChangeFrameNotification 后附加附件视图,其他三个将正常触发。

于 2012-12-05T22:33:07.803 回答