Xcode 从Alertview获取textfield的值,然后在Tableview中重新加载该值

Xcode 从Alertview获取textfield的值,然后在Tableview中重新加载该值,xcode,uitableview,uialertview,Xcode,Uitableview,Uialertview,有人能告诉我如何根据在alertbox中单击的按钮获取alertbox的文本字段数据吗 i、 我正在使用一个包含一些行的tableview。现在,当用户单击“添加”时,它会提示一个alertview,其中包含文本字段,并包含两个按钮1.确定2.取消 现在,如果按Ok,则输入的文本将重新加载到表格中 - (void)tableView:(UITableView *)aTableView commitEditingStyle (UITableViewCellEditingStyle)editingS

有人能告诉我如何根据在alertbox中单击的按钮获取alertbox的文本字段数据吗

i、 我正在使用一个包含一些行的tableview。现在,当用户单击“添加”时,它会提示一个alertview,其中包含文本字段,并包含两个按钮1.确定2.取消

现在,如果按Ok,则输入的文本将重新加载到表格中

- (void)tableView:(UITableView *)aTableView commitEditingStyle (UITableViewCellEditingStyle)editingStyle 
  forRowAtIndexPath:(NSIndexPath *)indexPath 
{

if (editingStyle == UITableViewCellEditingStyleDelete) 
{
    [arry removeObjectAtIndex:indexPath.row];
    [tableView1 reloadData];
} else if (editingStyle == UITableViewCellEditingStyleInsert)
{
  UIAlertView *alert = [[UIAlertView alloc] 
                          initWithTitle:@"Enter Name Here" 
                          message:@"blank" 
                          delegate:self 
                          cancelButtonTitle:@"Dismiss"
                          otherButtonTitles:@"OK!", nil];

    UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12, 45, 260, 25)];

    /*CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0, 60);

    [alert setTransform:myTransform];*/

    [myTextField setBackgroundColor:[UIColor whiteColor]];
    [alert addSubview:myTextField];

    /*How to get textfield text in the Table from here */
    [alert show];

}

}

根据您的代码,下面的代码将为您提供texfield

    UITextField* textField = (UITextField*)[alertView.subviews objectAtIndex:5];
NSLog(@"%@",textField.text);

在alertView委托中实现此操作以获取文本字段值。

在.h文件中声明此文本字段,然后在任何需要的地方使用它。