【发布时间】:2011-06-16 07:46:09
【问题描述】:
我的设置:主窗口带有一个标签栏控制器(包括一个标签栏)和两个UIViewControllers,它们都分配给扩展UIViewController的同一个接口。这个自定义接口实现了一个IBOutlet Webview 和一个加载 URL 的 void。在主.m 上的didSelectViewController 上,我尝试拨打LoadURL。
.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
视图控制器的.h
#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
}
我在每个 void 上都设置了断点,然后它们就会被调用。但是我的 webView 没有显示任何内容。
除此之外,我收到了 2 个警告:
'UITabBarController' may not respond to '-LoadURL:'
Semantic Issue: Method '-LoadURL:' not found (return type defaults to 'id')
【问题讨论】:
-
你是在视图控制器头文件中定义LoadURL方法吗?如果是这样,您如何定义它?
-
感谢您的回复。我已经编辑了我的帖子以包含 .h 文件。
标签: objective-c ios