Ios 当文本视图辞去第一响应者(失去焦点)时使视图移动
下面的代码在文本字段辞职时移动视图,但当我将其更改为使用文本视图时,在指示行上出现错误Ios 当文本视图辞去第一响应者(失去焦点)时使视图移动,ios,objective-c,Ios,Objective C,下面的代码在文本字段辞职时移动视图,但当我将其更改为使用文本视图时,在指示行上出现错误 -(void)textViewDidEndEditing:(UITextView *)textView { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.3]; [UIView setAnimationBeginsFromCurrentState:TRUE]; self.view.
-(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
,但不知道如何处理它们。+
告诉它将它们相加,并将结果传递到函数中。您必须向右滚动,它被注释掉://throws error Expected')哦,对不起。该错误可能与self.view.frame.origin.y
之后的“200.
”有关。应该在那里吗?200是它跳跃的像素数。textViewDidBeginEditing的值为-200。至少在textfield版本中,当您更改号码时,跳转的数量会发生变化。但是没有运算符。我认为句号也不好。self.view.frame.origin.y200。
语法不正确。如果你的意思是+200
,你需要说+200
不要为同一个参数给出两个数字。ObjC究竟应该如何知道你想要什么呢。这不是php…造成的。谢谢