我创建了自定义类,文件名为showBlock.h和showBlock.m,用于以编程方式加载UIWebView。showBlock.m的实现如下:
#import "showBlock.h"
@implementation showBlock;
@synthesize mainViewContObj;
- (void) showView {
UIWebView *aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
aWebView.autoresizesSubviews = YES;
aWebView.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
[aWebView setDelegate:[self mainViewContObj]];
NSString *urlAddress = @"http://localhost/test/index.php";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[aWebView loadRequest:requestObj];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
[[[self mainViewContObj] view] addSubview:aWebView];
}
@end
它正常工作,并加载具有HTML内容的index.php文件,但我想在Safari浏览器中打开此HTML文件的链接,我需要做哪些事情?