我在这里尝试了 3 或 4 篇关于此的帖子,但没有使用文件路径,我无法使用 WKWebView,它适用于 UIWebView,请有人帮助我。是的,我对此很陌生,我在今晚发帖之前尝试了一整天,所以易于理解的说明会很棒。谢谢。
.h 文件:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *contentWebView;
@end
.m 文件:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize contentWebView;
- (void)viewDidLoad {
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"LockBackground" ofType:@"html"];
NSURL * fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
NSURLRequest * myNSURLRequest = [[NSURLRequest alloc]initWithURL:fileURL];
[contentWebView loadRequest:myNSURLRequest];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end