簡體   English   中英

如何在目標中添加確認彈出窗口?

[英]How to add a confirming pop up window in objective?

比如java中的JOptionPane,當用戶做某事時。 我要求確認,你確定要刪除文件嗎? 或者無論如何。 用戶確認它,然后我檢測用戶在兩個按鈕之間選擇了什么,然后根據用戶選擇做某事

目標c中有這樣的東西嗎? 鏈接PLZ和一些指導方針

謝謝大家

您正在尋找UIAlertView控制器。

我相信你想要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];

你想要做的是檢查在otherButtonTitles:下點擊的按鈕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"); } 

}

在條件下,您正在檢查用戶正在單擊的按鈕。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM