views:

13

answers:

1

You know how if you click and hold on a link in safari (4 iphone obviously) it gives you of options like "open in new window", "Open". "Copy" etc?

how do you call this and is it possible to get a UIBarButtonItem to do this (but every time it is clicked not just when held down)?

Thanks

A: 

This is how you show this menu:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                         delegate:self 
                                                cancelButtonTitle:@"Cancel", 
                                           destructiveButtonTitle:nil
                                                otherButtonTitles:@"Button 1", @"Button 2", @"Button 3", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

[actionSheet showInView:[self view]];
[actionSheet release];

In order to connect it to UIBarButtonItem just point the bar button item to a selector that will include the code above.

Don't forget to implement - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex method of UIActionSheetDelegate.

Michael Kessler