UIViewController があり、その中に UIWebView を配置しました
次に、これを .h ファイルに追加しました。
#import <UIKit/UIKit.h>
@interface BuildBusinessController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *theWebView;
@end
これを.mファイルとして持っています
#import "BuildBusinessController.h"
@interface BuildBusinessController ()
@end
@implementation BuildBusinessController
@synthesize theWebView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
theWebView.delegate = self;
}
- (void)viewDidUnload
{
[self setTheWebView:nil];
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)viewDidAppear:(BOOL)animated
{
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"build_business" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:htmlFile];
NSURLRequest *rq = [NSURLRequest requestWithURL:url];
[theWebView loadRequest:rq];
}
@end
しかし、build_business.html ファイルはビュー内でレンダリングされず、次の行で警告が表示されます: theWebView.delegate = self; それは言う:
互換性のない型 BuildBusinessController *const_string から ID 'UIWebViewDelegate に割り当てています
ここで私が間違っていることを誰かが知っていますか?小さなことを忘れているように感じます:)