ボタンでアクションをさせるよ [UIActionSheet]

スクリーンショット 2013-10-29 22.18.33

Main.storyboudにボタンをラベルを配置

ViewController.hにボタン/ラベルを入れる
[php]
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIActionSheetDelegate>{
}
@property (strong, nonatomic) IBOutlet UILabel *mylabel;
– (IBAction)btn:(id)sender;

@end
[/php]

ViewController.mにボタンを配置とアクションを追加
[php]
– (IBAction)btn:(id)sender {
UIActionSheet *actionSheet =
[[UIActionSheet alloc] initWithTitle:@"テストタイトル"
delegate:self
cancelButtonTitle:@"キャンセル"
destructiveButtonTitle:@"タイトル"
otherButtonTitles:@"処理1",@"処理2", nil];
[actionSheet showInView:self.view]; //呼び出し
}

– (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex{
_mylabel.text =
[NSString stringWithFormat:@"ボタン",buttonIndex];
}
@end
[/php]

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です