Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c ';UITABBARC控制器';可能不响应'-方法';_Objective C_Ios - Fatal编程技术网

Objective c ';UITABBARC控制器';可能不响应'-方法';

Objective c ';UITABBARC控制器';可能不响应'-方法';,objective-c,ios,Objective C,Ios,我的设置:带有一个选项卡栏控制器(包括一个选项卡栏)和两个UIViewControllers的主窗口,都分配给扩展UIViewController的同一界面。此自定义接口实现了一个IBOutletWebview和一个加载URL的void。在主屏幕上选择ViewController。我尝试调用加载URL 视图控制器的.m @implementation MyTabBarController @synthesize webView; - (id)initWithNibName:(NSString

我的设置:带有一个选项卡栏控制器(包括一个选项卡栏)和两个
UIViewController
s的主窗口,都分配给扩展
UIViewController
的同一界面。此自定义接口实现了一个
IBOutlet
Webview和一个加载URL的void。在主屏幕上选择ViewController。我尝试调用
加载URL

视图控制器的.m

@implementation MyTabBarController
@synthesize webView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
return [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
}

- (void) LoadURL: (NSString*)s {
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:s]]];
}

- (void)dealloc {
[super dealloc];
}
@end
  #import <UIKit/UIKit.h>

@interface MyTabBarController : UIViewController {
IBOutlet UIWebView *webView;
}

- (void) LoadURL: (NSString*)s;

@property (nonatomic, retain) UIWebView *webView;

@end
视图控制器的.h

@implementation MyTabBarController
@synthesize webView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
return [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
}

- (void) LoadURL: (NSString*)s {
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:s]]];
}

- (void)dealloc {
[super dealloc];
}
@end
  #import <UIKit/UIKit.h>

@interface MyTabBarController : UIViewController {
IBOutlet UIWebView *webView;
}

- (void) LoadURL: (NSString*)s;

@property (nonatomic, retain) UIWebView *webView;

@end
我在每个空洞上设置断点,然后调用它们。但是我的网络视图没有显示任何内容

除此之外,我收到了两条警告:

'UITabBarController' may not respond to '-LoadURL:'
Semantic Issue: Method '-LoadURL:' not found (return type defaults to 'id')

您的
-LoadURL:
方法未在
UITabBarController
上定义。也许你是有意的

[self LoadURL:@"http://google.com"];

如果您确定它不是UIViewController而是它的子类,则很可能必须强制转换它

[(MyTabBarController*)myController LoadURL:@"http://google.com"]

谢谢你的回复@戴夫,我不明白,抱歉:赛尔夫没有为我工作。可能是因为-LoadURL不在同一个文件中,而是在自定义视图控制器的.m中@诺亚不工作,仍然得到警告。谢谢,是的,我已经想到了。它是UIViewController的一个子类。但是我得到了未声明的“MyTabBarController”(首次用于此函数)您能告诉我如何导入它吗?在文件的开头
#导入“MyTabBarController.h”
,或者无论调用什么文件,您的类都驻留在Hanks中。既然我已经导入了它,MyTabBarController就可以解决了。但我仍然收到一条警告:“MyTabBarController可能不会响应“-LoadURL:”您是否在MyTabBarController.h中声明了-LoadURL:?你能给我们看一下这个文件吗?你在视图控制器头文件中定义了LoadURL方法吗?如果是,你如何定义它?谢谢你的回复。我已经编辑了我的帖子以包含.h文件。