ViewDidLoad
このコードをメソッドに追加し、
UIBarButtonItem *arrow = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showActionSheet)] autorelease];
self.navigationItem.rightBarButtonItem = arrow;
showActionSheetメソッドのコードを記述し、ファイルを追加しUIActionSheet *actionSheet in .h
て@propertyと@synthesizeを指定します。
#pragma mark - Button Methods
-(void)showActionSheet
{
// Here is code for UIActionSheet
self.actionSheet= [[UIActionSheet alloc]initWithTitle:@" " delegate:self cancelButtonTitle:@"Hide Action" destructiveButtonTitle:nil otherButtonTitles:@"Send email", @"Send message", nil];
[self.actionSheet showInView:self.view];
//self.actionSheet.tag=1;
}
のデリゲートメソッドを追加UIActionSheet
#pragma mark - UIActionSheet Delegate Methods
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
// code for selected first Button.
}
else if(buttonIndex == 1)
{
// code for selected Second Button.
}
}