iOS-UIActionSheet(已弃用)

已由 UIAlertController 代替

已由 UIAlertController 代替

已由 UIAlertController 代替

UIActionSheet基本写法

 .h 写代理 

 .m 写实现
UIActionSheet *actiongSheet = [[UIActionSheet alloc] initWithTitle:@"算是标题吧" 
  delegate:self  
  cancelButtonTitle:@"取消按钮吧,最下面吧" 
  destructiveButtonTitle:@"红色按钮吧" 
  otherButtonTitles:@"条目1", @"条目2", @"条目3", nil]; 
 [sheet showFromRect:view.bounds inView:view animated:YES]; 
 [sheet release]; 
}

actiongSheet.actionSheetStyle = UIActionSheetStyleDefault;///有几种,cmd + 左键
actiongSheet.cancelButtonIndex = actiongSheet.numberOfButtons-1;
[actiongSheet showInView:self.view];

问题来了,实际项目中,我们需要的是动态的编辑 otherButtonTitles,肿么办?
先设置为nil ,在添加
UIActionSheet *actiongSheet = [[UIActionSheet alloc] initWithTitle:@"请选择" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil, nil];
///////循环添加
for (int i = 0; i

你可能感兴趣的:(iOS-UIActionSheet(已弃用))