2013-07-17 77 views

回答

4

只需使用該代碼使使刪除按鈕destructiveButton

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure you want to delete this backup?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Backup" otherButtonTitles:nil,nil]; 
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque; 
[actionSheet showInView:self.view]; 
+0

非常感謝,它的工作完美 – NGOT

0
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure you want to delete this backup ?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete backup" otherButtonTitles:nil, nil]; 
    [actionSheet showInView:self.view]; 
0

試試下面的代碼

UIActionSheet *objActionSheet = [[UIActionSheet alloc] 
         initWithTitle:@"XYZ Message" 
         delegate:self 
         cancelButtonTitle:@"Cancel" 
         destructiveButtonTitle:@"Delete Backup" 
         otherButtonTitles:nil]; 
0

您可以從https://github.com/russj/MBActionSheet/下載示例項目,並可以自定義你的動作片。你可以設計你的按鈕,並添加使用下面的代碼

- (void)createButton:(CGRect)frm buttonTitile:(NSString *)title buttonIndex:(NSInteger)index 
{ 
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    btn.frame = frm; 
    if(index==0){ 
      [btn setBackgroundImage:[UIImage imageNamed:@"delete.png"] forState:UIControlStateNormal]; 
    } 
    else if(index==1){ 
      [btn setBackgroundImage:[UIImage imageNamed:@"cancel.png"] forState:UIControlStateNormal]; 
    } 

    [btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; 
    [btn setTag:index]; 
    [sheetView addSubview:btn]; 
} 

到actionsheet和調用此方法要在其中創建的動作片。