Objective c 没有可见的@interface声明选择器错误
“NSObject”没有可见的@interface,它在上声明了选择器“viewDidLoad” 台词:Objective c 没有可见的@interface声明选择器错误,objective-c,uiviewcontroller,nsobject,Objective C,Uiviewcontroller,Nsobject,“NSObject”没有可见的@interface,它在上声明了选择器“viewDidLoad” 台词: [super viewDidLoad]; [_viewWeb loadRequest:requestObj]; [super didReceiveMemoryWarning]; UIViewControllerHUB.m #import "UIViewControllerHUB.h" @interface UIViewControllerHUB () @property (stron
[super viewDidLoad];
[_viewWeb loadRequest:requestObj];
[super didReceiveMemoryWarning];
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
#import <Foundation/Foundation.h>
@interface UIViewControllerHUB : NSObject
@property (strong, nonatomic) IBOutlet UIView *viewWeb;
@end
viewDidLoad
是一种UIViewController
方法。若要修复此问题,请更改为从中继承:
#import <Foundation/Foundation.h>
@interface UIViewControllerHUB : UIViewController
@property (strong, nonatomic) IBOutlet UIView *viewWeb;
@end
#导入
@界面UIViewControllerHUB:UIViewController
@属性(强,非原子)ibuiview*viewWeb;
@结束
在您的代码中,UIView
没有可见的@界面
在线声明选择器“loadRequest:”为什么会出现此错误,是因为loadRequest
不是UIView
的方法。但尽管如此,它仍然是UIWebView
的方法。有关更多信息,请参阅此。因此,只需将UIView
替换为UIWebView
并检查
//对此发表评论
//@property (strong, nonatomic) IBOutlet UIView *viewWeb;
//修改这个
@property (strong, nonatomic) IBOutlet UIWebView *viewWeb;
注意:-因为您已经创建了UIView
的出口。所以删除相同的拖拽UIWebVIEW,然后重新连接<代码>出口>代码> <代码> uiWebVIEW/COD>也考虑重命名您的类,按照惯例<>代码> UI >代码>前缀仅适用于UIKIT类。如果您有新问题,请提出新问题;不要编辑你的旧版本。在这种情况下,您可能希望首先检查代码,并在其他问题中查找类似错误。您的代码是正确的。唯一的问题是LoadRequest方法不是UIView方法,而是UIWebView。我已经更新了答案,请跟随。
@property (strong, nonatomic) IBOutlet UIWebView *viewWeb;