iOS 8.3中不推荐使用actionSheet:didDismissWithButtonIndex。我现在必须使用的新方法是什么?
这些都是不推荐的,但我没有找到改进它的解决方案:iOS 8.3中不推荐使用actionSheet:didDismissWithButtonIndex。我现在必须使用的新方法是什么?,ios,objective-c,xcode,uiactionsheet,dismiss,Ios,Objective C,Xcode,Uiactionsheet,Dismiss,这些都是不推荐的,但我没有找到改进它的解决方案: [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Take Photo", nil) style:UIAlertActionStyleDefault handler:^(__unused UIAlertAction *action) { [self
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Take Photo", nil) style:UIAlertActionStyleDefault handler:^(__unused UIAlertAction *action)
{
[self actionSheet:nil didDismissWithButtonIndex:0];
}]];
以及:
最后:
- (void)actionSheet:(__unused UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
switch (buttonIndex)
{
case 0:
{
sourceType = UIImagePickerControllerSourceTypeCamera;
break;
}
case 1:
非常感谢。从苹果的,它清楚地说你应该使用苹果的,它清楚地说你应该使用你可以使用
UIAlerController
,因为UIActionSheet
在iOS
8.3之后被弃用
请查看以下代码以供参考
UIAlertController* alert = [UIAlertController
alertControllerWithTitle:nil // Must be "nil", otherwise a blank title area will appear above our two buttons
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* button0 = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
// UIAlertController will automatically dismiss the view
}];
UIAlertAction* button1 = [UIAlertAction
actionWithTitle:@"Camera"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action)
{
// The user tapped on "Camera"
}];
UIAlertAction* button2 = [UIAlertAction
actionWithTitle:@"Photo Library"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action)
{
// The user tapped on "Camera"
}];
[alert addAction:button0];
[alert addAction:button1];
[alert addAction:button2];
[self presentViewController:alert animated:YES completion:nil];
希望这将引导您进入UIAlterController
,以取代UIActionSheet
谢谢。您可以使用
UIAlerController
,因为UIActionSheet
在iOS
8.3之后被弃用
请查看以下代码以供参考
UIAlertController* alert = [UIAlertController
alertControllerWithTitle:nil // Must be "nil", otherwise a blank title area will appear above our two buttons
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* button0 = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
// UIAlertController will automatically dismiss the view
}];
UIAlertAction* button1 = [UIAlertAction
actionWithTitle:@"Camera"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action)
{
// The user tapped on "Camera"
}];
UIAlertAction* button2 = [UIAlertAction
actionWithTitle:@"Photo Library"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action)
{
// The user tapped on "Camera"
}];
[alert addAction:button0];
[alert addAction:button1];
[alert addAction:button2];
[self presentViewController:alert animated:YES completion:nil];
希望这将引导您进入UIAlterController
,以取代UIActionSheet
谢谢⌘-单击
ui操作表
。在那里你会发现如何替换它的建议。⌘-单击ui操作表
。在那里你会发现如何替换它的建议。