Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.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/date/2.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
当textView成为第一响应者时,iOS视图将返回到原始位置_Ios_Keyboard - Fatal编程技术网

当textView成为第一响应者时,iOS视图将返回到原始位置

当textView成为第一响应者时,iOS视图将返回到原始位置,ios,keyboard,Ios,Keyboard,你好,提前谢谢你 我正在移动动画块中的视图帧位置。移动视图后,我点击文本视图以允许编辑/输入。点击textView时,我先前移动的视图会弹出回其原始(未移动)帧位置 我不确定我在这里做错了什么 这是我如何设置不同帧位置以设置动画的方式 //Books active and rest position will effect other elements (paper and paperTextView) self.bookRestPosition = CGRectMake((self.v

你好,提前谢谢你

我正在移动动画块中的视图帧位置。移动视图后,我点击文本视图以允许编辑/输入。点击textView时,我先前移动的视图会弹出回其原始(未移动)帧位置

我不确定我在这里做错了什么

这是我如何设置不同帧位置以设置动画的方式

    //Books active and rest position will effect other elements (paper and paperTextView)
self.bookRestPosition = CGRectMake((self.view.frame.size.width * 0.10), (self.view.frame.size.height * 0.4), self.view.frame.size.width, self.view.frame.size.height);
self.bookActivePosition = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y +100, self.view.frame.size.width, self.view.frame.size.height);
self.bookOpenPosition = CGRectMake(self.bookActivePosition.origin.x, self.bookActivePosition.origin.y, 20, self.bookActivePosition.size.height);


self.quillRestPosition = self.quill.frame;
self.quillActivePosition = CGRectMake(self.quill.frame.origin.x, self.view.frame.origin.y -200, self.quill.frame.size.width, self.quill.frame.size.height);

self.woodTableRestPosition = self.view.frame;
self.woodTableActivePosition = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y -200, self.view.frame.size.width, self.view.frame.size.height +200);


self.paperRestPosition = self.bookRestPosition;
self.paperActivePosition = CGRectMake(self.bookOpenPosition.size.width,     self.bookActivePosition.origin.y, self.bookActivePosition.size.width, self.bookActivePosition.size.height);

self.paperTextViewRestPosition = self.bookRestPosition;
self.paperTextViewActivePosition = self.paperActivePosition;
self.paperTextView.editable = NO;


self.paper.alpha = 0.0;
self.paperTextView.alpha = 0.0;

self.paper.frame = self.bookRestPosition;
self.paperTextView.frame = self.bookRestPosition;
这就是我制作动画的方式

- (IBAction)onBookTapped:(UITapGestureRecognizer *)sender {
if (self.logCover.frame.origin.x == self.bookRestPosition.origin.x) {

    [UIView animateWithDuration:1.0
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         [self activateLogAndViewsAssociated];
                     } completion:^(BOOL finished) {
                         NSLog(@"Book Slid up!");
                     }];
}
else if (self.logCover.frame.origin.x == 0){
    [UIView animateWithDuration:1.0
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         [self everythingAtRestPosition];
                     } completion:^(BOOL finished) {
                         NSLog(@"Book Slid Down!");
                     }];
}
}

- (IBAction)swipeBookLeft:(UISwipeGestureRecognizer *)sender {
//if (self.logCoverImage.frame.origin.x == 0) {
    self.paper.alpha = 1.0;
    [UIView animateWithDuration:1.0
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         [self.logCover     setFrame:self.bookOpenPosition];
                         self.editButton.alpha = 1.0;
                         self.editButton.enabled = YES;
                     } completion:^(BOOL finished) {
                         NSLog(@"Book Has Opened!");

                             //This must be here.  The paperTextView is     what the swipe right gesture is attached to
                         self.paperTextView.alpha = 1.0;
//                             self.logCoverImage.alpha = 0.0;
//                             self.quill.alpha = 0.0;
                     }];
//}
}
- (IBAction)onPaperSwipeRight:(UISwipeGestureRecognizer *)sender {
[UIView animateWithDuration:1.0
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     [self.logCover setFrame:self.bookActivePosition];
                     self.editButton.alpha = 0.0;
                     self.editButton.enabled = NO;
                 } completion:^(BOOL finished) {
                     NSLog(@"Book Has Closed!");
                     //self.paper.alpha = 0.0;

//                         [NSUserDefaults *log = [NSUserDefaults standardUserDefaults];
//                         [log setObject:self.paperTextView     forKey:@"textLog"];

                 }];
}
- (IBAction)onBookSwipeDown:(UISwipeGestureRecognizer *)sender {
if (self.logCover.frame.origin.x == 0) {
    [UIView animateWithDuration:1.0
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         [self everythingAtRestPosition];
                     } completion:^(BOOL finished) {
                         NSLog(@"Book Slid Down!");
                     }];
}
}
- (IBAction)onBookSwipeUp:(UISwipeGestureRecognizer *)sender {
    if (self.logCover.frame.origin.x == self.bookRestPosition.origin.x) {

    [UIView animateWithDuration:1.0
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         [self activateLogAndViewsAssociated];
                     } completion:^(BOOL finished) {
                         NSLog(@"Book Slid up!");
                     }];
}
}

- (void)animateAtStartup
{
self.logCover.frame = CGRectMake(self.view.frame.size.width,     self.view.frame.size.height, self.bookRestPosition.size.width,     self.bookRestPosition.size.height);
[UIView animateWithDuration:1.0
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     [self.logCover setFrame:self.bookRestPosition];
                 } completion:^(BOOL finished) {
                     NSLog(@"Book Slid Down!");
                 }];
}
这就是按下编辑按钮时发生的情况

- (IBAction)onEditButtonPressed:(id)sender
{
self.paperTextView.editable = YES;
[self.paperTextView becomeFirstResponder];
}

这是因为自动布局。使用“自动布局”时不应设置任何帧。如果你这样做了,当视图需要重新调整时,视图将恢复到由其约束确定的位置。太棒了!好吧,这完全有道理。我只是不知道规则。因此,不要设置帧更改的动画。您如何建议我移动视图,使它们不会“重新布局”到其原始位置?您可以使IBOutlet适应任何需要修改的约束,并更改其在代码中的“常量”值。我也有同样的问题,如何删除自动布局?