我有html字符串,我想在网页视图中加载,但我希望有一些值,我得到的结果所以我想在运行时添加它们像
我有一个字符串belwo我希望这个值加上行 这样它应该显示访问诊所的狗的数量? 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>";
答案 0 :(得分: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];
希望它有所帮助。快乐的编码:)