Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.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 UITextView UIPickerView键盘动画问题_Ios_Uitextfield_Uitextview_Uipickerview_Uiviewanimation - Fatal编程技术网

Ios UITextView UIPickerView键盘动画问题

Ios UITextView UIPickerView键盘动画问题,ios,uitextfield,uitextview,uipickerview,uiviewanimation,Ios,Uitextfield,Uitextview,Uipickerview,Uiviewanimation,我一直在绞尽脑汁来解决这个问题。我有一个UITableView有UITextView和UIPickerView如下: 1.每行都有一个UITextView 2.最后一行有一个UITextView和一个不可编辑的UITextField,打开一个UIPickerView 以下是一个屏幕截图: 文本为All的控件是UITextField,它打开一个UIPickerView 以下是我在制作动画时面临的问题: 1.在重新调整UITextView时,UITableView滚动到顶部(它应该滚动到UITex

我一直在绞尽脑汁来解决这个问题。我有一个
UITableView
UITextView
UIPickerView
如下:
1.每行都有一个
UITextView

2.最后一行有一个
UITextView
和一个不可编辑的
UITextField
,打开一个
UIPickerView

以下是一个屏幕截图:

文本为All的控件是
UITextField
,它打开一个
UIPickerView

以下是我在制作动画时面临的问题:
1.在重新调整
UITextView
时,
UITableView
滚动到顶部(它应该滚动到
UITextView
位置)。尝试使用
ScrollToRowatineXpath
,仍然没有帮助

- (BOOL)textViewShouldEndEditing:(UITextView *)textView
{
    txtViewActive = nil;
    [self animateTextView:NO];
    return YES;
}

- (void)textViewDidBeginEditing:(UITextView *)textView
{
    [txtUser resignFirstResponder];
    [pickerView removeFromSuperview];
    if ([textView.text isEqualToString:NSLocalizedString(@"write_a_reply", nil)]) {
        textView.text = @"";
        textView.textColor = [UIColor blackColor];
    }

    [self animateTextView:YES];
}  

- (void) animateTextView: (BOOL) up
{
    const int movementDistance = 140;
    const float movementDuration = 0.3f;

    int movement = (up ? -movementDistance : movementDistance);

    [UIView beginAnimations: @"anim" context: nil];
    [UIView setAnimationBeginsFromCurrentState: YES];
    [UIView setAnimationDuration: movementDuration];
    self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, movement);
    [tableMessageDetail scrollToRowAtIndexPath:indexPathScrollTo
                              atScrollPosition:UITableViewScrollPositionNone
                                      animated:YES];
    [UIView commitAnimations];
}  
  • 以我创建
    UIPickerView
    的方式,当键盘出现时,我无法设置动画

    txtUser = [[UITextField alloc]init];
    UIToolbar *toolbarUsers = [[UIToolbar alloc] init];  
    [toolbarUsers setBarStyle:UIBarStyleDefault];  
    [toolbarUsers sizeToFit];  
    UIBarButtonItem *flexButtonUsers = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];  
    UIBarButtonItem *doneButtonUsers =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(resignKeyboard)];  
    NSArray *itemsArrayUsers = [NSArray arrayWithObjects:flexButtonUsers, doneButtonUsers, nil];  
    [toolbarUsers setItems:itemsArrayUsers];  
    [txtUser setInputAccessoryView:toolbarUsers];  
    arrUsers = [NSMutableArray new];  
    [arrUsers addObject:NSLocalizedString(@"all", nil)];  
    [arrUsers addObject:[[message.MessageByFirstName componentsSeparatedByString:@" "] objectAtIndex:0]];  
    pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 150, self.view.frame.size.width, 150)];
    [pickerView setDataSource: self];  
    [pickerView setDelegate: self];  
    pickerView.showsSelectionIndicator = YES;  
    txtUser.inputView = pickerView;  
    
  • 我正在寻找一个稳定的解决方案,其中:

    • UITextView
      UIPickerView
      键盘动画不会冲突(如果用户先点击
      UITextView
      ,然后点击
      UITextField
      ,则会出现双动画)
    • UIPickerView
      动画
    可能
    UIKeyboardWillShowNotification
    UIKeyboardWillHideNotification
    很方便,但我无法干净地使用它们。

    尝试使用库来解决键盘问题。下载此库并将该文件夹放入项目中,无需导入任何类,它将自动处理键盘

    无需删除textViewDidBeginEditing方法中的pickerview

    只需尝试以下代码

    -(void) viewWillAppear:(BOOL)animated
     {
       [self.PickerVw removeFromSuperview];
       txtAge.inputView = self.PickerVw;
     }
    
     -(void)textViewDidBeginEditing:(UITextField *)textField
     {
         arr1 = [NSMutableArray new];
         if (textField.tag == 1)
         {
           int min =  9;
           int max = 100;
           for (int i = min ; i < max; i++)
           {
              [arr1 addObject:[NSString stringWithFormat:@"%d",(i+1)]];
           }
           [textView becomeFirstResponder];
           self.picker.tag = 1;
          }
          [self.picker reloadAllComponents];
     }
    
    -(void)视图将显示:(BOOL)动画
    {
    [self.PickerVw removeFromSuperview];
    txtAge.inputView=self.PickerVw;
    }
    -(无效)textViewDidBeginEditing:(UITextField*)textField
    {
    arr1=[NSMutableArray new];
    如果(textField.tag==1)
    {
    int min=9;
    int max=100;
    对于(int i=min;i
    我希望这对你有帮助。如果您还有任何疑问,请告诉我。

    尝试使用库解决您的键盘问题。下载此库并将该文件夹放入项目中,无需导入任何类,它将自动处理键盘

    无需删除textViewDidBeginEditing方法中的pickerview

    只需尝试以下代码

    -(void) viewWillAppear:(BOOL)animated
     {
       [self.PickerVw removeFromSuperview];
       txtAge.inputView = self.PickerVw;
     }
    
     -(void)textViewDidBeginEditing:(UITextField *)textField
     {
         arr1 = [NSMutableArray new];
         if (textField.tag == 1)
         {
           int min =  9;
           int max = 100;
           for (int i = min ; i < max; i++)
           {
              [arr1 addObject:[NSString stringWithFormat:@"%d",(i+1)]];
           }
           [textView becomeFirstResponder];
           self.picker.tag = 1;
          }
          [self.picker reloadAllComponents];
     }
    
    -(void)视图将显示:(BOOL)动画
    {
    [self.PickerVw removeFromSuperview];
    txtAge.inputView=self.PickerVw;
    }
    -(无效)textViewDidBeginEditing:(UITextField*)textField
    {
    arr1=[NSMutableArray new];
    如果(textField.tag==1)
    {
    int min=9;
    int max=100;
    对于(int i=min;i

    我希望这对你有帮助。如果您还有任何疑问,请告诉我。

    UITableView是否可以处理键盘外观上的UI移动?你能在没有任何手动动画的情况下试试看吗?UITableView不能处理键盘外观上的UI移动吗?你能在没有任何手动动画的情况下试试看吗?