Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.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 在情节提要上单击UITableViewController时显示UIAlertView或任何对话框进度_Ios_Ios7_Uitableview_Uialertview_Mbprogresshud - Fatal编程技术网

Ios 在情节提要上单击UITableViewController时显示UIAlertView或任何对话框进度

Ios 在情节提要上单击UITableViewController时显示UIAlertView或任何对话框进度,ios,ios7,uitableview,uialertview,mbprogresshud,Ios,Ios7,Uitableview,Uialertview,Mbprogresshud,我有一个故事板,其中有一个导航控制器和一个uiviewcontroller作为我的根,之后我有几个UITableViewController,通过单元格单击上的push seague连接 我需要的是,在当前控制器关闭并显示新控制器时,显示UIAlertView或一些进度对话框(如MBProgressHUD) 我已尝试在单击单元格上设置UIAlertView: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPat

我有一个故事板,其中有一个导航控制器和一个uiviewcontroller作为我的根,之后我有几个UITableViewController,通过单元格单击上的push seague连接

我需要的是,在当前控制器关闭并显示新控制器时,显示UIAlertView或一些进度对话框(如MBProgressHUD)

我已尝试在单击单元格上设置UIAlertView:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"I am dismissing"
                                       message:nil
                                      delegate:nil
                             cancelButtonTitle:nil
                             otherButtonTitles:nil];
    [alert show];
}

但是警报会一直显示到下一个控制器出现,当在单元格上执行单击时,如何显示警报?

我找到的解决方案:

准备工作:
  • 使控制器符合协议
    UIAlertViewDelegate


    示例:
    @界面YourViewController:UITableViewController


    @界面YourViewController:UITableViewController

  • 在序列图像板中,设置序列标识符。在这个例子中,我将其称为CellSegue。
    (要做到这一点,请单击故事板中的segue,转到属性检查器,然后出现标识符字段)

  • 您将需要2个属性。
    @property(强,非原子)UITableView*selectedCellTableView
    @property(强,非原子)NSIndexPath*selectedCellIndexPath


  • 编码: 下面的方法显示
    alertview
    ,并通过返回
    nil
    来阻止选择单元格。我们希望记住要选择的单元格,因此我们将之前准备的属性设置为:

    -(nsindepath*)tableView:(UITableView*)tableView将选择rowatindexpath:(nsindepath*)indepath{
    UIAlertView*av=[[UIAlertView alloc]initWithTitle:nil消息:@“警报”委托:自取消按钮:@“确定”其他按钮:nil];
    _selectedCellTableView=tableView;
    _selectedCellIndexPath=indexPath;
    [视听节目];
    返回零;
    }
    
    最后,在
    UIAlertViewDelegate
    方法中,我们处理一个按钮单击:

  • 我们从
    \u selectedCellTableView
    获取位于
    \u selectedCellIndexPath
    的单元格
  • 我们执行CellSegue segue并将该小区设置为发送方
  • -(无效)alertView:(UIAlertView*)alertView单击按钮索引:(NSInteger)按钮索引{
    //1
    UITableViewCell*cell=[\u selectedCellTableView cellForRowAtIndexPath:\u selectedCellIndexPath];
    //2
    [self-PerformsgueWithIdentifier:@“CellSegue”发送方:cell];
    }
    
    我希望这就是你想要的:)