从下面的一段非常简单的代码中,我在旋转时在iOS 7和8之间存在奇怪的行为差异:
我创建了一个非常简单的项目,以确保它不是我的主项目的副作用,但事实并非如此。
是否存在记录在案的行为差异?
的问候。 塞巴斯蒂安。
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:self.view.window];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)keyboardWillShow:(NSNotification*)notification
{
NSLog(@"Keyboard will show.");
}
-(void)keyboardWillHide:(NSNotification*)notification
{
NSLog(@"Keyboard will hide.");
}
@end
答案 0 :(得分:0)
塞巴斯蒂安 我认为您应该在viewDidLoad()中添加键盘通知,然后再试一次,希望它能为您提供帮助。