Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 8.3中不推荐使用actionSheet:didDismissWithButtonIndex。我现在必须使用的新方法是什么?_Ios_Objective C_Xcode_Uiactionsheet_Dismiss - Fatal编程技术网

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操作表
。在那里你会发现如何替换它的建议。