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]