开发者

'UITabBarController' may not respond to '-method'

My setup: MainWindow with a Tab Bar Controller (including a Tab Bar) and two UIViewControllers, both assigned to the same interface which extends UIViewController. This custom interface implements a IBOutlet Webview and a void that loads a URL. On didSelectViewController on the main .m I try to call LoadURL.

.m of the view controller

@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 of the view controller

  #import <UIKit/UIKit.h>

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

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

@property (nonatomic, retain) UIWebView *webView;

@end

.m of the main window

- (void) tabBarController: (UITabBarController *) myController didSelectViewController: (UIViewController *) viewController {
[myController LoadURL:@"http://google.com"]; // WARNING 
}

I put breakpoints on each of the voids and they get called. But my webView doesn't show any content.

Other than that I got 2 warnings:

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


Most likely you have to cast it, if you are sure it isn't a UIViewController but a subclass of it

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


Your -LoadURL: method is not defined on UITabBarController. Perhaps you mean to do

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

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜