【代码笔记】iOS-UIActionSheet动态添加按钮
2017-06-16 09:21
411 查看
一,效果图。
二,代码。
RootViewController.h
RootViewController.m
二,代码。
RootViewController.h
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UIActionSheetDelegate> @end
RootViewController.m
//点击任何处,弹出UIActionSheet -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UIActionSheet *sheet=[[UIActionSheet alloc]initWithTitle:@"标题" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil, nil]; // 逐个添加按钮(比如可以是数组循环) [sheet addButtonWithTitle:@"Item A"]; [sheet addButtonWithTitle:@"Item B"]; [sheet addButtonWithTitle:@"Item C"]; // 同时添加一个取消按钮 [sheet addButtonWithTitle:@"Cancel"]; sheet.cancelButtonIndex = sheet.numberOfButtons-1; [sheet showInView:self.view]; }
相关文章推荐
- 【代码笔记】iOS-UIActionSheet动态添加按钮
- iOS中UIActionSheet动态添加按钮
- iOS: 学习笔记, 动态添加按钮
- 【代码笔记】iOS-UIActionSheet字体的修改
- IOS项目笔记——按钮属性和代码添加
- UIActionSheet动态添加按钮
- 【代码笔记】iOS-UIActionSheet字体的修改
- 【代码笔记】iOS-清除图片缓存UIActionSheet
- iPhone开发之动态添加UIActionSheet按钮
- 动态添加UIActionSheet按钮
- iPhone开发之动态添加UIActionSheet按钮
- 动态添加UIActionSheet按钮
- iOS虚拟键盘上添加动态按钮
- iOS学习之动态添加Button和监听UIAlertView按钮
- 【代码笔记】iOS-增加右侧按钮
- ios开发笔记之十三 --用代码来监听按钮的点击
- ios开发笔记之十四--用代码来监听按钮的点击
- 【代码笔记】iOS-DropDownDemo-下拉按钮效果
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- iOS 11开发教程(十八)iOS11应用视图之使用代码添加按钮