我的设置:带有选项卡栏控制器(包括选项卡栏)的MainWindow和两个UIViewController
s,都被分配到延伸UIViewController
的同一接口。这个自定义接口实现了IBOutlet
Webview和一个加载URL的void。在主要.m上的didSelectViewController
我尝试拨打LoadURL
。'UITabBarController'可能不会响应'-method'
的.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
的.m主窗口
- (void) tabBarController: (UITabBarController *) myController didSelectViewController: (UIViewController *) viewController {
[myController LoadURL:@"http://google.com"]; // WARNING
}
我把断点上每个的.H空隙,他们会被召唤。但我的webView不显示任何内容。除此之外
我得到了2个警告:
'UITabBarController' may not respond to '-LoadURL:'
Semantic Issue: Method '-LoadURL:' not found (return type defaults to 'id')
你定义的视图控制器头文件使用loadURL方法的一个子类?如果是这样,你怎么定义它? – csano 2011-06-15 22:39:43
感谢您的回复。我编辑了我的文章以包含.h文件。 – Blisra 2011-06-15 22:47:41