2011-08-06 14 views
0

私のアプリでiPhone:UIWebViewでHTMLを表示しているときの問題

私はHTMLを使ってレポートを生成し、UIWebViewに表示しています。

私はwebviewでデータを書式設定するためにHtmlテーブルを使用しています。

より良く理解するためにいくつかのスクリーンショットの取り付け:第2のスクリーンの最初のラウンドマークアップに示すよう

enter image description here

enter image description here

は、テーブルのアライメントが見当違いです。

このテーブルを生成するために使用するコードは次のとおりです。

[html appendFormat:@"<h3 style =\"font-family: Arial\">Expressive <h3><br/>"]; 

        NSString *htmlString1= @"<table border=\"1\" style=\"width: 100%; border: 1px #000 solid; border-collapse: collapse; font-size: 13px; font-family: sans-serif;\">"; 

        for (int i=0; i<2; i++) //Two Rows 
        { 
         htmlString1 = [htmlString1 stringByAppendingString:@"<tr>"]; 

         for (int j=0; j<2; j++) //Two Columns 
         { 
          if (i==0) 
          { 
           if(j==0) 
           { 
            htmlString1 = [htmlString1 stringByAppendingString:[NSString stringWithFormat:@"<th style=\"text-align:center;font-size:16;width:30;height:20\"><b>Correct-%.00f%%</b></th>",correctPercent]]; 

           } 
           else if(j==1) 
           { 
            htmlString1 = [htmlString1 stringByAppendingString:[NSString stringWithFormat:@"<th style=\"text-align:center;font-size:16;width:30;height:20\"><b>Incorrect-%.00f%%</b></th>",incorrectPercent]]; 

           } 

          } 
          else 
          { 
           if(j==0) 
           { 
            NSString *val = @""; 
            if([[[newArray valueForKey:@"Expressive"]valueForKey:@"CorrectResults"] count]>0) 
            { 
             val = [[[newArray valueForKey:@"Expressive"]valueForKey:@"CorrectResults"] componentsJoinedByString:@"<br/>"]; 
            } 
            htmlString1 = [htmlString1 stringByAppendingString:[NSString stringWithFormat:@"<td style=\"text-align:center;width:40%;height:50;\">%@</td>",val]]; //E 

           } 
           else if(j==1) 
           { 
            NSString *val = @""; 
            if([[[newArray valueForKey:@"Expressive"] valueForKey:@"InCorrectResults"] count]>0) 
            { 
             val = [[[newArray valueForKey:@"Expressive"]valueForKey:@"InCorrectResults"] componentsJoinedByString:@"<br/>"]; 
            } 
            htmlString1 = [htmlString1 stringByAppendingString:[NSString stringWithFormat:@"<td style=\"text-align:center;width:40%;height:50;\">%@</td>",val]]; 

           } 

          } 

         } 
         htmlString1 = [htmlString1 stringByAppendingString:@"</tr>"]; 
        } 

        htmlString1 = [htmlString1 stringByAppendingString:@"</table>"]; 

        [html appendString:htmlString1]; 
        [html appendString:@"<br/>"]; 

どのようにこの問題を解決できますか?

答えて

0

列の幅を指定するために使用pxまたは%

htmlString1 = [htmlString1 stringByAppendingString:[NSString stringWithFormat:@"<th style=\"text-align:center;font-size:16;width:30%;height:20px\"><b>Correct-%.00f%%</b></th>",correctPercent]]; 

などが...

+0

私は '%'で試してみましたが、それでも私は、適切なHTMLテーブルを取得していないです! – Devang

+0

でも 'px'で試してみましたが、まだ動作していません。他の解決策? – Devang

+1

%とpxが彼らがやるべきことをしないなら、私は知らないでしょう。両方の列が最大100%を加算する必要があることに注意してください。 に幅を設定した場合は、もう​​に設定する必要はありません。 –

関連する問題