2013-02-27 56 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. 
相关问题