Ios 在情节提要上单击UITableViewController时显示UIAlertView或任何对话框进度
我有一个故事板,其中有一个导航控制器和一个uiviewcontroller作为我的根,之后我有几个UITableViewController,通过单元格单击上的push seague连接 我需要的是,在当前控制器关闭并显示新控制器时,显示UIAlertView或一些进度对话框(如MBProgressHUD) 我已尝试在单击单元格上设置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
- (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
(要做到这一点,请单击故事板中的segue,转到属性检查器,然后出现标识符字段)
@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
的单元格-(无效)alertView:(UIAlertView*)alertView单击按钮索引:(NSInteger)按钮索引{
//1
UITableViewCell*cell=[\u selectedCellTableView cellForRowAtIndexPath:\u selectedCellIndexPath];
//2
[self-PerformsgueWithIdentifier:@“CellSegue”发送方:cell];
}
我希望这就是你想要的:)