objective-c 没有可见的@interface for 声明选择器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20725801/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
no visible @interface for declares the selector errors
提问by Nihir
I'm getting No visible @interface for 'NSObject' declares the selector 'viewDidLoad' on the lines:
我得到 No visible @interface for 'NSObject' 在行上声明了选择器 'viewDidLoad':
[super viewDidLoad];
[_viewWeb loadRequest:requestObj];
[super didReceiveMemoryWarning];
UIViewControllerHUB.m
UIViewControllerHUB.m
#import "UIViewControllerHUB.h"
@interface UIViewControllerHUB ()
@property (strong, nonatomic) NSMutableArray *subItems;
@end
@implementation UIViewControllerHUB
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *fullURL = @"http://conecode.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_viewWeb loadRequest:requestObj];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
UIViewControllerHUB.h
UIViewControllerHUB.h
#import <Foundation/Foundation.h>
@interface UIViewControllerHUB : NSObject
@property (strong, nonatomic) IBOutlet UIView *viewWeb;
@end
How can I fix this?
我怎样才能解决这个问题?
EVERYTHING ABOVE IS NOW RESOLVED.
以上所有问题现在都已解决。
New error below:
新错误如下:
Now getting 'No visible @interface for 'UIView' declares the selector 'loadRequest:' on line
现在得到“没有可见的@interface for 'UIView' 声明了选择器 'loadRequest:' 在线
[_viewWeb loadRequest:requestObj];
采纳答案by Hussain Shabbir
In your code 'No visible @interface for UIViewdeclares the selector 'loadRequest:' on linewhy you are getting this error is becuase loadRequestis not the method of UIView. But in-spite of that it is the method of UIWebView. For more refer this UIWebView documentation. So just replace UIViewto UIWebViewand check
在您的代码中, 'No visible @interface forUIView声明选择器'loadRequest:' 在线为什么您收到此错误是因为loadRequest不是UIView. 但尽管如此,它是 的方法UIWebView。有关更多信息,请参阅此UIWebView 文档。因此,只需更换UIView到UIWebView和检查
//Comment this
//评论这个
//@property (strong, nonatomic) IBOutlet UIView *viewWeb;
//Modify this
//修改这个
@property (strong, nonatomic) IBOutlet UIWebView *viewWeb;
Note:- As you have created outlet of UIView. So delete the same and drag-drop UIWebView and then reconnect the outletto UIWebView
注意:-由于您已经创建了UIView. 所以删除相同并拖放 UIWebView 然后重新连接outlet到UIWebView
回答by jszumski
viewDidLoadis a UIViewControllermethod. To fix it, change to inherit from that:
viewDidLoad是一种UIViewController方法。要修复它,请更改为继承自:
#import <Foundation/Foundation.h>
@interface UIViewControllerHUB : UIViewController
@property (strong, nonatomic) IBOutlet UIView *viewWeb;
@end

