Iphone 一个视图控制器中的多个UIActionSheet

Iphone 一个视图控制器中的多个UIActionSheet,iphone,cocoa-touch,uiactionsheet,Iphone,Cocoa Touch,Uiactionsheet,如果只有一个-actionSheet:ClickedButtonIndex:方法,如何将多个UIActionSheet添加到单个UIViewController。您可以为每个操作表设置一个标记,并在委派方法中检查标记以执行必要的功能。为您的操作表设置一个名称或标记,然后执行以下操作 -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if(actio

如果只有一个
-actionSheet:ClickedButtonIndex:
方法,如何将多个
UIActionSheet
添加到单个
UIViewController
。您可以为每个操作表设置一个标记,并在委派方法中检查标记以执行必要的功能。

为您的操作表设置一个名称或标记,然后执行以下操作

  -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
 {
   if(actionSheet==yourActionsheet1)
     {
      //your logic
       }
     if(actionSheet==yourActionsheet2)
     {
      //your logic
       }
    }

希望此帮助可以创建多个操作表,如下所示:

actionSheet1 = [[UIActionSheet alloc] initWithTitle:@"Where to go"
                                                   delegate:self
                                          cancelButtonTitle:@"cancel"
                                     destructiveButtonTitle:@"Store 2"
                                          otherButtonTitles:@"Store 3",@"Store 4",@"Store 5",@"View Store Profile",nil];
 actionSheet2 = [[UIActionSheet alloc] initWithTitle:@"Where to go"
                                                   delegate:self
                                          cancelButtonTitle:@"cancel"
                                     destructiveButtonTitle:@"Store 1"
                                          otherButtonTitles:@"Store 3",@"Store 4",@"Store 5",@"View Store Profile",nil];
actionSheet3 = [[UIActionSheet alloc] initWithTitle:@"Where to go"
                                                   delegate:self
                                          cancelButtonTitle:@"cancel"
                                     destructiveButtonTitle:@"Store 1"
                                          otherButtonTitles:@"Store 2",@"Store 4",@"Store 5",@"View Store Profile",nil];
&在那之后,检查哪一个动作表被调用 -(void)actionSheet:(UIActionSheet*)actionSheet DidDismissionWithButtonIndex:(NSInteger)buttonIndex{

if(actionSheet==actionSheet1)
{
}
else if(actionSheet==actionSheet2)
{
}
else if(actionSheet==actionSheet3)
{
}

谢谢。你知道如何设置按钮的颜色吗?例如,红色的删除按钮?@Helium3:red color是actionsheet中破坏性按钮标题的默认颜色。你只需在声明actionsheet时声明
DestructiveButtontile=@“Delete”
。希望这对你有所帮助。