Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 当文本视图辞去第一响应者(失去焦点)时使视图移动_Ios_Objective C - Fatal编程技术网

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…造成的。谢谢