在NSstring中为UIweb视图分配HTML标签字符串



如何将HTML标签字符串格式直接分配给字符串,以便我可以直接在UiWEB VIEW中显示它

 <tr>
      <td align="center"><b>    Disclaimer</b></td>
   </tr>
     <tr>
       <td colspan="2" style="text-align:justify" class="ImageBorder">
   <p>
Personal Trainer is an endeavor by Bhasinsoft to provide in depth details and knowledge on exercises and workout regimes to work towards a health and fit body. While great care has been taken to provide as accurate knowledge and details as possible by referring to knowledge in public domain, guidance by fitness specialists and doctors, Bhasinsoft is not responsible for the accuracy of the data.
The data is provided AS IS and you understand that Bhasinsoft is not responsible for the accuracy, usefulness or safety resulting from the use of the content. You further understand and acknowledge that you may be exposed to content that is inaccurate, offensive, indecent, or objectionable, and you agree to waive, and hereby do waive, any legal or equitable rights or remedies you have or may have against Bhasinsoft with respect thereto, and, to the extent permitted by applicable law, agree to indemnify and hold harmless Bhasinsoft, its owners, operators, affiliates, licensors, and licensees to the fullest extent allowed by law regarding all matters related to your use of the content.
YOU AGREE THAT YOUR USE OF THE CONTENT SHALL BE AT YOUR SOLE RISK. TO THE FULLEST EXTENT PERMITTED BY LAW, BHASINSOFT, ITS OFFICERS, DIRECTORS, EMPLOYEES, AND AGENTS EXCLUDE ALL WARRANTIES, EXPRESS OR IMPLIED, IN CONNECTION WITH THE SERVICES AND YOUR USE THEREOF. TO THE FULLEST EXTENT PERMITTED BY LAW, BHASINSOFT EXCLUDES ALL WARRANTIES, CONDITIONS, TERMS OR REPRESENTATIONS ABOUT THE ACCURACY OR COMPLETENESS OF THIS CONTENT AND ASSUMES NO LIABILITY OR RESPONSIBILITY FOR ANY (I) ERRORS, MISTAKES, OR INACCURACIES OF CONTENT, (II) PERSONAL INJURY OR PROPERTY DAMAGE, OF ANY NATURE WHATSOEVER, RESULTING FROM YOUR ACCESS TO AND USE OF OUR SERVICES OR THE CONTENT, AND/OR (III) ANY ERRORS OR OMISSIONS IN ANY CONTENT OR FOR ANY LOSS OR DAMAGE OF ANY KIND INCURRED AS A RESULT OF THE USE OF ANY CONTENT. BHASINSOFT DOES NOT WARRANT, ENDORSE, GUARANTEE, OR ASSUME RESPONSIBILITY FOR ANY PRODUCT OR SERVICE ADVERTISED OR OFFERED BY A THIRD PARTY THROUGH THE SERVICES OR ANY HYPERLINKED SERVICES OR FEATURED IN ANY BANNER OR OTHER ADVERTISING, AND BHASINSOFT WILL NOT BE A PARTY TO OR IN ANY WAY BE RESPONSIBLE FOR MONITORING ANY TRANSACTION BETWEEN YOU AND THIRD-PARTY PROVIDERS OF PRODUCTS OR SERVICES. AS WITH THE PURCHASE OF A PRODUCT OR SERVICE THROUGH ANY MEDIUM OR IN ANY ENVIRONMENT, YOU SHOULD USE YOUR BEST JUDGMENT AND EXERCISE CAUTION WHERE APPROPRIATE.
  </p>

所以我可以很容易地用这个方法显示它的格式

 self.webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 14 , 320, 343)];
NSString *tttt=[NSString stringWithString:@" <tr> <td align="center"><b>Disclaimer</b></td></tr> ";
[  self.webView loadHTMLString:self.app.musclesl baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
[self.secondView addSubview:self.webView];

Do like,

NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSString *pathToHtml = @"html";
NSURL *baseURL = [[NSURL alloc] initFileURLWithPath:pathToHtml isDirectory:YES];
NSString *html = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]    
                             pathForResource:@"nameOfFile" ofType:@"html"                                                               
                             inDirectory:@"html"] 
                         encoding:NSUTF8StringEncoding error:nil];
[webview loadHTMLString:html baseURL:baseURL];

我认为loadHTMLString()应该工作,

[self.webView loadHTMLString:tttt];

最新更新