【发布时间】:2016-08-03 13:01:10
【问题描述】:
我想为 iOS8 使用 UIActionSheet,但它已被弃用,我不知道如何使用更新的方式来使用它...
查看旧代码:
-(void)acoesDoController:(UIViewController *)controller{
self.controller = controller;
UIActionSheet *opcoes = [[UIActionSheet alloc]initWithTitle:self.contato.nome delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:@"other", nil];
[opcoes showInView:controller.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
//switch case of the buttons
}
为了清楚起见,在此示例中,操作表在 UITableView 索引中长按后被激活。
我怎样才能以正确的方式实现上面的代码?
【问题讨论】:
-
为了将来参考,如果您查看UIActionSheet 的文档,它会清楚地标记为自 iOS8 起已弃用,它甚至会告诉您替换类是什么。当您访问UIAlertController 的文档时,它甚至会为您提供如何使用它的示例。学习阅读文档是改进的重要第一步。
-
感谢您的提示!我还在使用 Objective-c。
标签: ios objective-c ios8 deprecated uiactionsheet