下面的代码在文本字段辞职时移动视图,但是当我将其更改为使用文本视图时,我在指示的行上出现错误。
-(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];
}
答案 0 :(得分:1)
你忘了一个加号!
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
,但不知道如何处理它们。 +
告诉它将它们添加到一起并将结果传递给函数。