2012-12-03 33 views
0

在模擬器上運行時沒有問題,但通知未在設備上發佈(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 

任何幫助表示讚賞。

UPDATE:

開始了一個新的項目把一切離開這裏的方法是視圖控制器,它的全部。

// 
// 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本身。它可能與配置或代碼本身之外的某些事情有關嗎?

+0

它不適用於任何設備或不適用於您擁有的所有設備? –

+0

剛剛檢查,它在iPhone上正常工作。只有在我所有的iPad上都無法觸發。 –

+0

你可以將自己設置爲零的觀察者,這會給你所有的觀察。如果通知正在觸發,您可以使用它來進行健全性檢查。 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someselector :) name:nil object:nil];然後只記錄通知名稱。 – Bergasms

回答

5

這是一個很好的無證行爲。

當鍵盤被分割時,這3個通知不會被觸發。但是,似乎在通常會觸發之前附加UITextField.inputAccessoryView,即使鍵盤被分割,它們也會觸發。因此,在收到UIKeyboardWillChangeFrameNotification後附加附件視圖,其他三個將正常啓動。

相關問題