gpt4 book ai didi

iphone - 如何在iphone中设置html +css add

转载 作者:可可西里 更新时间:2023-11-01 06:24:56 25 4
gpt4 key购买 nike

如何在iphone中设置html +css add

   webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0,320,458)];
webView.delegate=self;
[self.view addSubview:webView];


// HTML files are stored in the main bundle
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];

NSString *filename = @"index";
NSString *fullPath = [NSBundle pathForResource:filename ofType:@"html" inDirectory:path];
[fullPath stringByReplacingOccurrencesOfString:@"/" withString:@"_"];

// load a HTML from a file
// NSString *chapter_filename = [NSString stringWithFormat:@"Section%@", filename];
// NSString *sectionHTMLPath = [[NSBundle mainBundle] pathForResource:fullPath ofType:@"html"];

NSString* htmlContent = [NSString stringWithContentsOfFile:fullPath encoding:NSUTF8StringEncoding error:nil];

// add a generic template and the css file directive
NSString* htmlString = @"<!doctype html xmlns:fb=@\"http://ogp.me/ns/fb#\"><head><meta charset=\"utf-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"><title>Ways Group</title><meta name=\"description\" content=\"An very basic example of how to use the Wookmark jQuery plug-in.\"><meta name=\"author\" content=\"Christoph Ono\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><link href=\"landing-page/css/jquerysctipttop.css\" rel=\"stylesheet\" type=\"text/css\"><!-- Link to the built CSS --><link rel=\"stylesheet\" href=\"landing-page/css/modal.css\"><link rel=\"stylesheet\" href=\"css/main.css\"><link rel=\"stylesheet\" href=\"css/style.css\"><link rel=\"stylesheet\" href=\"css/menu.css\" type=\"text/css\" media=\"screen\" /><!-- CSS Reset --><link rel=\"stylesheet\" href=\"css/reset.css\"><link href=\"css/social-likes.css\" rel=\"stylesheet\"><script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js\"></script><script src=\"js/social-likes.js\"></script><!-- Styling for your grid blocks --><style type=\"text/css\">max-height: 300px;</style></head><body>%@</body></html>";
// load the html into a web view

NSURL *url = [NSURL fileURLWithPath:htmlContent];
[webView loadHTMLString:[NSString stringWithFormat:htmlString, htmlContent] baseURL:url];

最佳答案

NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"html" inDirectory:nil];
NSString *htmlString = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
NSURL *Url = [NSURL fileURLWithPath:htmlFile];
[WebView loadHTMLString:htmlString baseURL:Url];

不要忘记在 html 中链接 css

    <link rel="stylesheet" type="text/css" href="Sample.css">

关于iphone - 如何在iphone中设置html +css add,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17292492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com