How can I add an external stylesheet to a UIWebView in Xcode?

前端 未结 4 1806

I have looked at various similar questions and answers and still cannot get this to work, so I\'m adding my own question:

I\'m playing with UIWebView. I can create a

4条回答
  •  误落风尘
    2020-12-14 09:45

    I think i have figured it out. the htmlString is simply an NSString we can replace text in it. this code worked for me

    NSString *info = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"your html file name" ofType:@"html"] encoding: NSUTF8StringEncoding error: &error];
    
    info=[info stringByReplacingOccurrencesOfString:@"styles.css" withString:@"stylesIPad.css"];
    

提交回复
热议问题