Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple UIActionSheets in one View Controller

How are multiple UIActionSheets added to a single UIViewController if there is only a single -actionSheet:clickedButtonAtIndex: method?

like image 284
some_id Avatar asked Feb 24 '11 07:02

some_id


2 Answers

Set a Name or Tag to your Action sheet and do some thing like this

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

hope this help

like image 177
Sat Avatar answered Oct 23 '22 12:10

Sat


You can create multiple action sheet as below:

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];

& after that chek out which action sheet is called by - (void) actionSheet: (UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{

if(actionSheet==actionSheet1)
{
}
else if(actionSheet==actionSheet2)
{
}
else if(actionSheet==actionSheet3)
{
}
like image 3
Aakil Ladhani Avatar answered Oct 23 '22 12:10

Aakil Ladhani