iOS之UIActionSheet

来源:互联网 发布:php授权码怎么做 编辑:程序博客网 时间:2024/05/16 19:00

1、.h

#import <UIKit/UIKit.h>@interface FKViewController : UIViewController <UIActionSheetDelegate>- (IBAction)clicked:(id)sender;@end

2、.m

#import "FKViewController.h"@interface FKViewController ()@end@implementation FKViewController- (void)viewDidLoad{[super viewDidLoad];}- (void)didReceiveMemoryWarning{[super didReceiveMemoryWarning];}- (IBAction)clicked:(id)sender {// 创建一个UIActionSheetUIActionSheet* sheet = [[UIActionSheet alloc]initWithTitle:@"请确认是否删除" // 指定标题delegate:self // 指定该UIActionSheet的委托对象就是该控制器自身cancelButtonTitle:@"取消" // 指定取消按钮的标题destructiveButtonTitle:@"确定" // 指定销毁按钮的标题otherButtonTitles:@"按钮一", @"按钮二", nil]; // 为其他按钮指定标题// 设置UIActionSheet的风格sheet.actionSheetStyle = UIActionSheetStyleAutomatic;[sheet showInView:self.view];}- (void)actionSheet:(UIActionSheet *)actionSheetclickedButtonAtIndex:(NSInteger)buttonIndex{// 使用UIAlertView来显示用户单击了第几个按钮UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"提示"message:[NSString stringWithFormat:@"您单击了第%d个按钮" , buttonIndex]delegate:nilcancelButtonTitle:@"确定"otherButtonTitles: nil];[alert show];}@end


0 0
原创粉丝点击