2013-02-27 54 views

回答

2
NSString *actionSheetTitle = @"Title You want to give";  //Action Sheet Title 
NSString *destructiveTitle = nil;      //Action Sheet Button Titles 
NSString *firstButtonTitle = @"Delete Drafts";    //Action Sheet 1st Button Title 
NSString *secondButtonTitle = @"Save Drafts";  //Action Sheet 2nd Button Title 
NSString *cancelTitle = @"Cancel";    //Action Sheet Cancel Button Title 

UIActionSheet *myActionSheet = [[UIActionSheet alloc] 
            initWithTitle:actionSheetTitle 
            delegate:self 
            cancelButtonTitle:cancelTitle 
            destructiveButtonTitle:destructiveTitle 
            otherButtonTitles:firstButtonTitle,secondButtonTitle, nil]; 

[myActionSheet showInView:self.view.parentViewController.view]; 
0
UIActionSheet *act = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Draft" otherButtonTitles:@"Save Draft", nil]; 

[act showInView:self.view]; 

從Class參考:

cancelButtonTitle:本取消按鈕的標題。該按鈕將自動添加到操作表中,並分配一個適當的索引,該索引可從cancelButtonIndex屬性中獲得。此按鈕以黑色顯示,表示它代表取消操作。如果您不想取消按鈕或在iPad上顯示操作表,請指定nil。

destructiveButtonTitle:破壞性按鈕的標題。此按鈕將自動添加到操作表中,並分配一個適當的索引,該索引可從destructiveButtonIndex屬性中獲取。此按鈕顯示爲紅色,表示它代表了破壞性行爲。如果您不想要破壞性按鈕,請指定nil。

我會使用一個破壞性的按鈕進行刪除,因爲那將是紅色的。然後在黑色下方的取消按鈕。

使用此方法給每個按鈕動作你需要的任何行動:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex. 
相關問題