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本身。它可能與配置或代碼本身之外的某些事情有關嗎?
它不適用於任何設備或不適用於您擁有的所有設備? –
剛剛檢查,它在iPhone上正常工作。只有在我所有的iPad上都無法觸發。 –
你可以將自己設置爲零的觀察者,這會給你所有的觀察。如果通知正在觸發,您可以使用它來進行健全性檢查。 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someselector :) name:nil object:nil];然後只記錄通知名稱。 – Bergasms