1

で検証を行っていUITableViewCellます。セルにはtextViewとカスタムボタンがあり、クリックすると、を含むポップオーバーがUIDatePickerView開き、ユーザーが日付を選択します。ここで日付の選択は必須です。そこで、以下のコードを使用して検証を行いました。すぐ次の行のセル内のtextViewBeginEditingデリゲートメソッド。textViewつまり、ユーザーが次の行をクリックするとtextView、前の行の値が検証されます。ここでは、検証は機能しているように見えますが、カーソルは現在のセルでまだ点滅しており、検証されている前のセルに移動しません。

UITableViewCell* myCell = (UITableViewCell*)textView.superview ;

UITextView *txtviewMycelltext;//=[[UITextView alloc]init];

for (UIView *view in myCell.subviews) 
{

  if([view isKindOfClass:[UILabel class]]) 
  {

      UILabel *lbl=view;
      lbl.text=[lbl.text stringByReplacingOccurrencesOfString:@"." withString:@""];
      int tablerowindex=[lbl.text intValue];
      NSLog(@"%@",lbl.text);
      break;
  }
  if([view isKindOfClass:[UITextView class]]) 
  {
      txtviewMycelltext=view;
  }
}



inttablerowindex-=1;

if(inttablerowindex>0)
{
  if([[arrActionvalues objectAtIndex:inttablerowindex1]objectForKey:KEY_FOLLOWUPDATE]==EMPTYSTRING)
  {
      UIAlertView *alert = [[UIAlertView alloc]
                                        initWithTitle: @"Alert"
                                        message: ALERT_FOLLOWUPDATE
                                        delegate: nil
                                        cancelButtonTitle:@"OK"
                                        otherButtonTitles:nil];
      [alert show];


//              UITableView *mytable=(UITableView *)((textView.superview).superview).superview;
      UITableView *myTable=(UITableView*)[[myCell superview]superview];

      NSIndexPath *indexPath = (NSIndexPath*)[myTable indexPathForCell:  
          (UITableViewCell*)textView.superview.superview];
      UITableViewCell *previousCell = (UITableViewCell*)[myTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section]];

      for (UIView *view in previousCell.subviews) 
      {
                      NSLog(@"%@",view);
                      if([view isKindOfClass:[UIView class]]) {

                          UIView *subView=view;
                          for(UIView *view2 in subView.subviews)
                          {

                              if([view2 isKindOfClass:[UITextView class]]) {
                                  UITextView *txt=view2;

                                  [txtviewMycelltext resignFirstResponder];
                                  [txt becomeFirstResponder];
                                   break;
                              }
                          }


                      }
                  }
              }
          }

カーソル位置を正しいセルに移動するために何をする必要があるか教えてください。

4

1 に答える 1

0

コードからはあまり明確ではありませんが、内部で検証を実行していると思いますtextViewDidEndEditing

textViewShouldEndEditingテキストビューの内容の検証を実行するための適切なデリゲートメソッドです。現在のテキストビューからフォーカスが切り替わらないようにする場合は、NOを返すことができます。

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextViewDelegate_Protocol/Reference/UITextViewDelegate.html#//apple_ref/occ/intfm/UITextViewDelegate/textViewShouldEndEditing

于 2012-12-11T08:01:16.280 に答える