ios - UIActionSheet 委托(delegate) self 警告

标签 ios objective-c xcode5 uiactionsheet

自从 iOS 7 推出以来,Objective-C 进行了大量改进和更改。我创建了一个 UIActionSheet下面并分配了delegateself这样我就可以对每次按下按钮来完成一个 Action 进行编程。

- (IBAction)sortButton
{
    UIActionSheet *sortSheet = [[UIActionSheet alloc]
                                initWithTitle:@"Sort By"
                                delegate:self
                                cancelButtonTitle:@"Cancel"
                                destructiveButtonTitle:@"Featured"
                                otherButtonTitles:@"Price", @"Brand", nil];

    [sortSheet showInView:self.view];
}

这是我用来检查用户在单击 UIAlertView 中的特定按钮时执行的操作的代码。 :

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex == 0)
    {
        UIAlertView *dueDateAlert = [[UIAlertView alloc]
                                     initWithTitle:@"Featured"
                                     message:@"This button formats the list for items based on Feature."
                                     delegate:nil
                                     cancelButtonTitle:nil
                                     otherButtonTitles:@"Ok", nil];

        [dueDateAlert show];
    }

    else if(buttonIndex == 1)
    {
        UIAlertView *creationDateAlert = [[UIAlertView alloc]
                                          initWithTitle:@"Price"
                                          message:@"This button formats the list for items based on Price."
                                          delegate:nil
                                          cancelButtonTitle:nil
                                          otherButtonTitles:@"Ok", nil];

        [creationDateAlert show];
    }

    else if(buttonIndex == 2)
    {
        UIAlertView *subjectAlert = [[UIAlertView alloc]
                                     initWithTitle:@"Brand"
                                     message:@"This button formats the list for items based on Brand."
                                     delegate:nil
                                     cancelButtonTitle:nil
                                     otherButtonTitles:@"Ok", nil];

        [subjectAlert show];
    }
}

当我运行这段代码时,我收到以下警告:Sending SecondViewController *const_strong to parameter of incomplete type 'id<UIActionSheetDelegate>self 上创作中的文字UIActionSheet .我假设它是在说我正在“低效”地做某事,我想知道需要更改哪些内容才能使此警告不出现。

最佳答案

您的类似乎没有确认 UIActionSheetDelegate 协议(protocol)。

检查你有类似的东西

@interface YourClass () <UIActionSheetDelegate>

关于ios - UIActionSheet 委托(delegate) self 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22263446/

相关文章:

iphone - xocde5 中没有具有有效签名身份的配置文件

ios - Xcode 中发生未知错误

ios - 为什么 MPMoviePlayerController 全屏按钮图标在 iOS 10 中变为字幕图标?

android - 解析 : Posts with the indication of logged in user liked or not

ios - presentingViewController 显示为 null

ios - 如何以只读方式设置 UICollectionViewCell 的属性

ios - Cocoapods 设置停留在终端上的 pod 设置命令上

ios - 当 View 已向上移动键盘时,UINavigationBar BarButtonItems 不响应点击

ios - 如何比较 2 个数组并将最后一项附加到第二个数组 iOS Swift 3

objective-c - 使用 NSURL 访问已保存照片中的图像并上传到 S3 的正确方法?