当文本视图作为第一响应者辞职时使视图移动(失去焦点)
Make view move when text view resigns as first responder (loses focus)
下面的代码在文本字段退出时移动视图,但是当我将其更改为使用文本视图时,我在指示的行上收到错误。
-(void)textViewDidEndEditing:(UITextView *)textView
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
[UIView setAnimationBeginsFromCurrentState:TRUE];
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y 200., self.view.frame.size.width, self.view.frame.size.height);//throws error Expected ')'
[UIView commitAnimations];
}
谁能找出错误来源? (郑重声明,textViewDidBeginEditing:
的非常相似的代码不会引发错误。)
以下也不会报错:
-(void)textViewDidBeginEditing:(UITextView *)textView
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
[UIView setAnimationBeginsFromCurrentState:TRUE];
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y -200., self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
您忘记加号了!
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y 200., self.view.frame.size.width, self.view.frame.size.height);
应该是:
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y + 200., self.view.frame.size.width, self.view.frame.size.height);
没有加号,编译器会看到 self.view.frame.origin.y
和 200
,但不知道如何处理它们。 +
告诉它将它们相加并将结果传递给函数。
下面的代码在文本字段退出时移动视图,但是当我将其更改为使用文本视图时,我在指示的行上收到错误。
-(void)textViewDidEndEditing:(UITextView *)textView
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
[UIView setAnimationBeginsFromCurrentState:TRUE];
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y 200., self.view.frame.size.width, self.view.frame.size.height);//throws error Expected ')'
[UIView commitAnimations];
}
谁能找出错误来源? (郑重声明,textViewDidBeginEditing:
的非常相似的代码不会引发错误。)
以下也不会报错:
-(void)textViewDidBeginEditing:(UITextView *)textView
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
[UIView setAnimationBeginsFromCurrentState:TRUE];
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y -200., self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
您忘记加号了!
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y 200., self.view.frame.size.width, self.view.frame.size.height);
应该是:
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y + 200., self.view.frame.size.width, self.view.frame.size.height);
没有加号,编译器会看到 self.view.frame.origin.y
和 200
,但不知道如何处理它们。 +
告诉它将它们相加并将结果传递给函数。