0

我有 html 字符串,我想在 Web 视图中加载,但我希望有一些值作为结果得到,所以我想在运行时将它们添加到其中

我有一个字符串,我希望将此值添加到行中,以便它显示访问诊所的狗数?12个这样

 NSString*dogspermonth=12;

 Number of dogs that visit clinic? <br>


 NSString*htmlString=@"<HTML>
 <HEAD>
 <TITLE>JAMSHED ALI</TITLE>
 </HEAD>
<BODY background="InsideBackgroundPage2.png">
<H6><font color="white">Cerenia Motion Sickness<br>
Model</br>Report
<p>Inputs</p>
<br>
 Number of dogs that visit clinic? <br>
 Number of dogs with motion sickness <br>
 Dogs treated with (per year):      <br>

Cerenia <br>                                       
Other prescription drugs<br>
Other means<br>                            
Other the counter drugs<br>  
<p>
Average cost to client for Cerenia prescription<br>      
Clinic markup<br><br>


Average number of dogs treated for car sickness<br>
Total number of dogs treated for car sickness<br>
Dogs treated with Cerenia<br>
Dogs treated with other drugs or interventions<br>

<br>  
  Profit for each Cerenia prescription<br>
  Annual Profit earned from Cerenia treatment<br>
  Potential annual profit increase  from using Cerenia to treat all dogs with motion sickness<br>
 Maximum annual profit if all dogs with car sickness were treated with Cerenia<br>
</BODY>
 </head>";
4

1 回答 1

0

首先

NSString*dogspermonth=12; //is wrong
NSString *dogspermonth=@"12"; //is correct if u want string else
NSInteger dogspermonth = 12; //will suffice

接下来你可以使用 stringWithFormat 像:

NSString *htmlString= [NSString stringWithFormat:@"<HTML>
 <HEAD>
 <TITLE>JAMSHED ALI</TITLE>
 </HEAD>
<BODY background="InsideBackgroundPage2.png">
<H6><font color="white">Cerenia Motion Sickness<br>
Model</br>Report
<p>Inputs</p>
<br>
 Number of dogs that visit clinic? %@<br> //%@ if string //%d if integer
 Number of dogs with motion sickness <br>
 Dogs treated with (per year):      <br>

Cerenia <br>                                       
Other prescription drugs<br>
Other means<br>                            
Other the counter drugs<br>  
<p>
Average cost to client for Cerenia prescription<br>      
Clinic markup<br><br>


Average number of dogs treated for car sickness<br>
Total number of dogs treated for car sickness<br>
Dogs treated with Cerenia<br>
Dogs treated with other drugs or interventions<br>

<br>  
  Profit for each Cerenia prescription<br>
  Annual Profit earned from Cerenia treatment<br>
  Potential annual profit increase  from using Cerenia to treat all dogs with motion sickness<br>
 Maximum annual profit if all dogs with car sickness were treated with Cerenia<br>
</BODY>
 </head>", dogspermonth];

希望能帮助到你。快乐编码:)

于 2012-05-23T06:24:22.453 回答