0

就像 java 中的 JOptionPane 一样,当用户做某事时。我要求确认,你确定要删除文件吗?或无论如何。用户确认它然后我检测用户在两个按钮之间选择了什么然后我根据用户选择做一些事情

目标c中有这样的东西吗?链接请和一些指导方针

谢谢大家

4

3 回答 3

2

You are looking for UIAlertView controller.

于 2012-07-05T15:07:23.647 回答
0

你想要做的是检查哪个按钮被点击otherButtonTitles:

像这样的东西:

UIAlertView *yourAlert = [[UIAlertView alloc] initWithTitle:@"Your title" message:@"Some String" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Confirm",nil];  

 [yourAlert show];

并记住将委托设置为自我。

然后:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {

if (buttonIndex == 0){

    //'Dismissing' code here

}

if (buttonIndex == 1){

    //Detecting whatever was under otherButtonTitles:
    //Right now it's checking if the user clicked "Confirm" -> So here you can put whatever you need
   NSLog(@"You clicked Confirm");

      }

}

在条件下,您正在检查用户正在单击哪个按钮。

于 2012-07-05T18:44:52.263 回答
0

我相信你想要UIActionSheet的,这是 Apple 推荐给用户的选择:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Some Message" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"button To Destroy or nil" otherButtonTitles:@"Choice 1", @"Choice 2", @"Choice 3", nil];
于 2012-07-05T15:10:57.373 回答