2016-07-10 52 views
0
[UIView animateWithDuration:0.3 delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{ 
      [viewMain setFrame:CGRectMake(0, 30, 1024, 378)]; 
     } completion:^(BOOL finished){ 
      [txtViewNote becomeFirstResponder]; //Its a TextView 
     }]; 

上面的代码大部分时间都正常工作。但有时候行iOS的TextView在UIView动画完成块之后得到崩溃

[txtNote becomeFirstResponder] 

导致崩溃。我有尝试抓住。但是碰撞不会阻挡。

+0

确保您从主线程调用动画。 – Raz

+0

我正在从主线程调用。 –

回答

0

我刚刚解决了这个问题。当我第二次来到这个视图时,它实际上发生了。 我有2个键盘观察者

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow :) name:UIKeyboardWillShowNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide :) name:UIKeyboardWillHideNotification object:nil];

但是在关闭视图时我没有移除观察者。这就是为什么当第二次来到这个视图时,核心代码无法处理它。不知道可可触摸中究竟有什么问题。但它解决了。

相关问题