0

我有一个项目的表格视图,当我单击一行时,我想将 uialertview 与带有按钮的 uiactionsheet 一起使用:编辑、删除和取消。当我单击按钮编辑时,我将打开一个模式视图。之前,我已经编辑了模态视图,当我单击一行时,我会去编辑模态视图,但现在我想添加 uiactionsheet,那么我该怎么做呢?

4

2 回答 2

1

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath在方法中编写 UIAlertview 或 UIActionsheet 。

我想这会对你有所帮助。

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"title" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"delete" otherButtonTitles:@"other 1", @"other 2", nil];
[actionSheet showInView:self.view];

//or
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"button",@"button1", nil];
    [alert show];

}
于 2012-08-21T07:06:28.480 回答
0

只需使用 UIAlertView 如下:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Edit", @"Remove", nil];
[alert show];

以下方法将检查按下了哪个按钮:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 
{
    switch (buttonIndex)
    {
         case 1:
         // perform Edit
             break;
         case 2:
         // perform Remove
             break;
         case 0:
         // perform Cancel, if any
             break;
    }
}
于 2012-08-21T07:04:40.557 回答