如何在iphone中设置html + css添加 [英] how to set the html +css add in the iphone

查看:114
本文介绍了如何在iphone中设置html + css添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iphone中设置html + css添加

how to set the html +css add in the iphone

   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

And Don't forget to link the css in html

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

这篇关于如何在iphone中设置html + css添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆