Search code examples
xcode4

add UIActionSheet without cancel button


i want to use UIActionSheet to allow user to choose one of two modes of my iphone app. so i do not need to show cancel button. i just want to ask him if he want to choose mode one or two. i tried not to add it but it did not allow me so how can i do it ?

note : i do not want to use alerts.

i use this code for adding UIActionSheet:

UIActionSheet *mySheet = [[UIActionSheet alloc] initWithTitle:@"choose one" delegate:nil cancelButtonTitle:@"tasks" destructiveButtonTitle:@"appointments" otherButtonTitles:nil];


[mySheet showInView:self.view];

Solution

  • Try:

    UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Share" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Mode 1",@"Mode 2", nil];
    [actionSheet showInView:self.view];
    

    Just set the cancelButtonTitle to nil