標籤:des style blog io ar os 使用 div on
警告框(AlertView)時模態的,不關閉它就不能做其它事情,所以不是下面幾種情況不應該隨便使用。
1、應用不能繼續執行。
如記憶體不足,沒有網路。一般僅僅須要一個button。
2、詢問還有一個解決方式。
不能執行時,詢問能否夠用3G網路。
3、詢問對操作的授權。
涉及到訪問隱私資訊的時候,須要使用者授權,如位置、相冊等。
動作表(ActionSheet)能夠給使用者提供多個選擇。能夠利用它將某個圖片發給新浪微博或者Facebook平台。
/ 實現UIAlertViewDelegate// 這個託付事實上沒實用到,就當練練手,由於警告表單有兩個按鈕索引// No為0,Yes為1-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"buttonIndex = %li", (long)buttonIndex);}// 實現UIActionSheetDelegate// 這個託付也沒有實際意義,就是在輸出命令表單輸出按下的索引數,以實現響應- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"buttonIndex = %li", (long)buttonIndex);}- (IBAction)testAlertView:(id)sender { // 警告框在上文已敘述 // delegate 參數用於設定該警告表單的託付對象 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message: @"Alert text goes here" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; [alertView show]; }- (IBAction)testActionSheet:(id)sender { // cancelButtonTitle 設定取消標題 // destructiveButtonTile 設定破壞型按鈕,僅僅能有一個在最上面 UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消"destructiveButtonTitle:@"破壞性按鈕" otherButtonTitles:@"新浪微博", nil]; // 設定為自己主動樣式 actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic; [actionSheet showInView:self.view];}
警告框和動作表(IOS開發)