UIActionSheet

#import "RootViewController.h"

@interface RootViewController ()<UIActionSheetDelegate>

@end

@implementation RootViewController

- (void)viewDidLoad {

[super viewDidLoad];

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 200, 50)];

button.layer.borderWidth = 2;

[button setTitle:@"showSheet" forState:(UIControlStateNormal)];

[button setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];

[self.view addSubview:button];

[button addTarget:self action:@selector(show) forControlEvents:(UIControlEventTouchUpInside)];

}

- (void)show {

//UIActionSheet , 继承于UIView .

//创建方法

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"提示" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"destructiveButton" otherButtonTitles:@"1", @"2", @"3", nil];

actionSheet.title = @"名字";//这里的 title 就是 创建方法里面的initWithTitle

actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;//设置样式

//按钮的index destructiveButton , 1 ,2, 3, cancel , 分别是0 1 2 3 4

/*//四种样式

UIActionSheetStyleDefault

UIActionSheetStyleAutomatic

UIActionSheetStyleBlackOpaque

UIActionSheetStyleBlackTranslucent

*/

[actionSheet showInView:self.view];

[actionSheet release];

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{//代理里面的方法, 点击了哪个按钮

if (0 == buttonIndex) {

NSLog(@"0");

} else if (1 == buttonIndex) {

NSLog(@"1");

} else if (2 == buttonIndex) {

NSLog(@"2");

} else if (3 == buttonIndex) {

NSLog(@"3");

} else {

NSLog(@"4");

}

}

@end

时间: 2024-10-08 06:02:19

UIActionSheet的相关文章

iOS学习-UIActionSheet详解

1 // 2 // ViewController.m 3 // UIActionSheet详解 4 // 5 // Created by 大欢 on 16/1/25. 6 // Copyright © 2016年 bjsxt. All rights reserved. 7 // 8 9 #import "ViewController.h" 10 11 @interface ViewController ()<UIActionSheetDelegate> 12 13 - (I

选择项弹窗IOS中UIActionSheet

IOS8后虽然出了新的控制器UIAlertController,但之前的UIAlertView,UIActionSheet依然可以使用. 一.初始化方法 - (instancetype)initWithTitle:(NSString *)title delegate:(id<UIActionSheetDelegate>)delegate cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSStrin

UIActionSheet底部弹出框

<底部弹出框来提示用户信息>    1.遵循代理方法<UIActionSheetDelete>    2.调用放法 [UIActionSheet *sheet=[UIActionSheet alloc]initWithTitle:@“通关了!” delegate:self cancelButtonTitle:@“取消” destructiveButtonTitle:@“购买” otherButtonTitles:@“购买1”,@“购买2”,nil]    [sheet showIn

iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建

1. Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) To create and manage alerts in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert. //UIAlertView和UI

iOS:提示框(警告框)控件UIActionSheet的详解

提示框(警告框)控件2:UIActionSheet 功能:当点击按钮或标签等时,弹出一个提示框,显示必要的提示,然后通过添加的按钮完成需要的功能.它与导航栏类似,它继承自UIView. 风格类型: typedef NS_ENUM(NSInteger, UIActionSheetStyle) { UIActionSheetStyleAutomatic        = -1,       //iOS系统自动默认的风格 UIActionSheetStyleDefault          = UIB

UIActionSheet(操作列表)

1 #import "AppDelegate.h" 2 3 @interface AppDelegate ()<UIActionSheetDelegate> 4 5 @end 6 7 @implementation AppDelegate 8 9 10 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 1

ios最新调用手机相册选取头像(UIActionSheet过期)

由于 UIActionSheet过期所以可以使用如下调用手机相册 前提不要忘记添加代理如下两个 UIImagePickerControllerDelegate,UINavigationControllerDelegate 还需要去plist文件里面添加相机相册权限否则要崩溃的哟 //更换头像 - (IBAction)changeHeadIM:(id)sender { //创建UIImagePickerController对象,并设置代理和可编辑 UIImagePickerController *

UIAlertView和UIActionSheet

##UIAlertView和UIActionSheet ```objc// cancelButton buttonIndex == 1// destructiveButton buttonIndex ==0 UIActionSheet *sheet =[[UIActionSheet alloc]initWithTitle:@"确定注销吗" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@&q

用block将UIAlertView与UIActionSheet统一起来

效果 1. 将代理方法的实例对象方法转换成了类方法使用 2. 要注意单例block不要长期持有,用完就释放掉 源码 https://github.com/YouXianMing/UIInfomationView // // UIInfomationView.h // Alert // // Created by YouXianMing on 15/6/23. // Copyright (c) 2015年 YouXianMing. All rights reserved. // #import <

096实现一个蓝色进度条效果(扩展知识:UIActionSheet和UIAlertView的使用)

效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController<UIActionSheetDelegate, UIAlertViewDelegate> 4 @property (strong, nonatomic) UIProgressView *progressView; 5 6 @end ViewController.m 1 #import &qu