ViewController.h
@interface ViewController : UIViewController
<
UIActionSheetDelegate
>
{
UIActionSheet *aActionSheet;
}
ViewController.m
- (IBAction) doClick:(id) sender
{
if (aActionSheet)
return;
aActionSheet = [[UIActionSheet alloc]
initWithTitle:@"Type1"
delegate:self
cancelButtonTitle:@"cancel"
destructiveButtonTitle:@"destructive"
otherButtonTitles:@"button1", @"button2", nil];
[aActionSheet showInView:self.view];
[aActionSheet release];
}
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex
{
[aLabelTitle setText:actionSheet.title];
[aLabelButton
setText:[NSString stringWithFormat:@"button%d", buttonIndex]];
}
- (void)actionSheet:(UIActionSheet *)actionSheet
didDismissWithButtonIndex:(NSInteger)buttonIndex
{
aActionSheet = nil;
}
iPadの場合はアクションシート表示させる際、下のようにした方がいいみたいです。
(これをiPhoneで見ると微妙に動きが違う。。。)
// iPhoneの場合 [aActionSheet showInView: self.view]; // iPadの場合 [aActionSheet showFromBarButtonItem: aButton animated:YES];
アクションシートに destructiveButtonTitle とありますがこれの使い方がよくわからずいろいろと調べてみたんですが、iOSヒューマンインターフェイスガイドラインを見ると
「害を及ぼす可能性のあるアクションを実行するボタンを提供する必要のある場合は、赤野ボタンを使用する」と記載があります。
。。。。。よくわかりませんでした。

0 件のコメント:
コメントを投稿