【问题标题】:No visible @interface for 'UIAlertView''UIAlertView' 没有可见的@interface
【发布时间】:2013-04-11 20:07:53
【问题描述】:

我一直在关注这个教程:http://www.appcoda.com/hello-world-build-your-first-iphone-app/

尝试创建一个简单的 iOS 6 应用。

但是我收到一个错误:@interface for 'UIAlertView'...

我有:

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

-(IBAction)showMessage;

@end

在我的AppDelegate.h 文件中和

-(IBAction)showMessage
{
    UIAlertView *helloWorldAlert = [[UIAlertView alloc]initWithTitle:@"my first app" message:@"hello there world!" delagate:nil cancelButtonTitle:@"dismiss" otherButtonTitles:nil];
    [helloWorldAlert show];
}

@end

在我的AppDelegate.m 文件中

我似乎不明白错误表示什么,我尝试了谷歌搜索但没有更接近找到解决方案,所以我在这里错过了什么?我必须解决什么问题?

确切的错误信息:

No visible @interface for 'UIAlertView' declares the selector 'initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:'

【问题讨论】:

  • 您的 AppDelegate.m 是否导入 AppDelegate.h?您的 AppDelegate.m 是否有 @implementation AppDelegate 行?
  • @rmaddy 确实 import AppDelegate.h 我也有@implementation AppDelegate
  • 显示完整的错误/警告信息。

标签: objective-c xcode ios6


【解决方案1】:

这行有错别字:

UIAlertView *helloWorldAlert = [[UIAlertView alloc]initWithTitle:@"my first app" message:@"hello there world!" delagate:nil cancelButtonTitle:@"dismiss" otherButtonTitles:nil];

delagate 替换为delegate

【讨论】:

  • @fermionoid:没问题,不客气。我只是想知道为什么错误消息在选择器中有“delegate”而不是“delagate”。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-11-07
  • 2015-05-17
  • 1970-01-01
  • 2017-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多