UIActionSheet添加多个otherButtonTitles

关于UIActionSheet,我们经常用到的就是

UIActionSheet *actionSheet = [[UIActionSheet
alloc]initWithTitle:@"请选择"
delegate:self
cancelButtonTitle:@"取消"destructiveButtonTitle:@"确定"
otherButtonTitles:@"1",@"2",@"3",nil];

但是当otherButtonTitles要显示一个数组的时候并不是用

[Ary
objectAtIndex:i]

如果这样用的话就会出错,就算不出错,也会pop[Ary count]次

所以,可以这样

UIActionSheet *actionSheet = [[UIActionSheet
alloc]initWithTitle:@"请选择"
delegate:self
cancelButtonTitle:@"取消"destructiveButtonTitle:@"确定"
otherButtonTitles:nil];

//

for(int j=0;j<[allAry
count];j++)

{

NSString *str=[[NSString
alloc]initWithFormat:@"%@",[allAry
objectAtIndex:j]];

[actionSheet
addButtonWithTitle:str];

}

[actionSheet
showInView:self.view];

大功告成

UIActionSheet添加多个otherButtonTitles,布布扣,bubuko.com

时间: 2024-08-07 21:32:28

UIActionSheet添加多个otherButtonTitles的相关文章

iOS8中的UIActionSheet添加UIDatePicker后,UIDatePicker不显示问题

解决方法: IOS8以前: UIActionSheet* startsheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:@"确定" destructiveButtonTitle:nil otherButtonTitles:nil, nil]; startsheet.tag = 333; [startsheet addSubview:datePicker]; [startsh

IOS开发中绘制地图线路

地图应用经常会涉及到线路的绘制问题,ios下可以使用MKMapView进行地图开发,使用 MKOverlayView进行线路的绘制. 使用MKMapView添加MKMap.framework 和CoreLocation.framework并导入 MapKit.h头文件. 新建一个基于视图的工程,修改头文件: 1 #import <UIKit/UIKit.h> 2 #import <MapKit/MapKit.h> 3 #import "CloMKAnnotation.h&

iOS开发摇动手势实现详解

1.当设备摇动时,系统会算出加速计的值,并告知是否发生了摇动手势.系统只会运动开始和结束时通知你,并不会在运动发生的整个过程中始终向你报告每一次运动.例如,你快速摇动设备三次,那只会收到一个摇动事件. 2,想要实现摇动手势,首先需要使视图控制器成为第一响应者,注意不是单独的控件.成为第一响应者最恰当的时机是在视图出现的时候,而在视图消失的时候释放第一响应者. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 -(BOOL)canBecomeFirstRespond

UIActionSheet动态添加按钮

效果图: 代码: //点击任何处,弹出UIActionSheet -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UIActionSheet *sheet=[[UIActionSheet alloc]initWithTitle:@"标题" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:ni

UIActionSheet上添加UIPickerView iOS8替换方案

此套替换方案采用"UIView+动画"方式实现(将UIActionSheet替换为UIView) 界面层级如下: 第一层:view(这一层充满整个屏幕,初始化时颜色为透明,userInteractionEnabled 为NO:显示时颜色为黑色,alpha值设置为0.6,userInteractionEnabled 为YES.作用是遮挡界面上其他的控件.) 第二层:contentView(这一层用来代替原来UIActionSheet.UIPickerView就添加在这一层上,颜色为白色,

选择项弹窗IOS中UIActionSheet

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

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

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

iOS开发——UI篇Swift篇&amp;UIAlertView/UIActionSheet

UIAlertView/UIActionSheet UIAlertView 1 //一个按钮的提醒 2 @IBAction func oneButtonAler() 3 { 4 //创建单一按钮提醒视图 5 let oneButtonAlert:UIAlertView = UIAlertView(title: "提醒", message: "这是一个简单的提醒视图", delegate: nil, cancelButtonTitle: "确定")

【学习ios之路:UI系列】UIAlertView. UIActionSheet 和 UIAlertController

1.UIAlertView ①简单无代理模式,代码如下: UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"这是一个警告" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",  @"按钮一", @"按钮二", nil