没有可见的@interface用于声明选择器错误

时间:2013-12-22 02:57:39

标签: objective-c uiviewcontroller nsobject

我得到'NSObject'没有可见的@interface声明选择器'viewDidLoad'on 这些行:

[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

我该如何解决这个问题?


以上所有解决方案现已解决。

以下新错误:

现在获得'UIView'的'不可见@interface'声明了选择器'loadRequest:' 在线

    [_viewWeb loadRequest:requestObj];

2 个答案:

答案 0 :(得分:1)

viewDidLoad是一种UIViewController方法。要修复它,请更改为继承:

#import <Foundation/Foundation.h>

@interface UIViewControllerHUB : UIViewController
@property (strong, nonatomic) IBOutlet UIView *viewWeb;

@end

答案 1 :(得分:1)

在您的代码中'UIView没有可见的@interface声明选择器'loadRequest:'在线为什么会出现此错误,因为loadRequest不是方法UIView。但尽管如此,它仍然是UIWebView的方法。有关详情,请参阅此UIWebView documentation。因此,只需将UIView替换为UIWebView并检查

即可

//评论此

//@property (strong, nonatomic) IBOutlet UIView *viewWeb;

//修改此

@property (strong, nonatomic) IBOutlet UIWebView *viewWeb;

注意: - 因为您创建了UIView的插座。因此,删除相同的并拖放UIWebView,然后将outlet重新连接到UIWebView