0

iOS 7 では、tableview の webview が iOS 5 で正常に動作するのに表示されません。iOS 7 では、tableview に webview を含むサンプル アプリケーションを作成しました。正常に動作します。ジェスチャ認識機能が原因である可能性があることを長い間検索した後、テーブルビューの Webview が表示されません。サンプル アプリケーションでこのシナリオをテストしました。しかし、それはうまくいきます。したがって、ジェスチャ認識機能には問題ありません。

tableview の webview が iOS 7 に表示されない理由は何ですか?

これはチェックするコードです:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
     return [app.resultsDic count];

}


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
  return  [NSString stringWithFormat:@"%d",section];    

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{   

   return 1;


}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 150;
}


- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

     static NSString *CellIdentifier = @"Cell";


    UIWebView *webView ;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;


    }
    NSUInteger row = [indexPath section];

    if ( [app.resultsDic count]>0 )
    {
        NSArray *cellSubviews = [cell subviews];
        for (UIView *currSubView in cellSubviews) {
            [currSubView removeFromSuperview];
        }
        webView = [[UIWebView alloc] initWithFrame:CGRectMake(15, 8, 280, 140)];
        webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.jpg"]];

        [cell addSubview:webView];

        //Retrieving Data into Dictionary and formatting the data using htmlString

        NSDictionary *resDict = [app.resultsDic valueForKey:[NSString stringWithFormat:@"%d",row]];

        NSMutableString *htmlString = [[NSMutableString alloc] init];
        NSString *initialString = [NSString stringWithFormat:@"<table>"];
        NSString *endString = [NSString stringWithFormat:@"</table>"];
        [htmlString appendString:initialString];
        for (int e = 0 ; e < [[resDict allKeys] count]; e++) {
            NSString *currentKey = [[resDict allKeys] objectAtIndex: e];


            [htmlString appendFormat:@"<tr><td ><b>%@</b></td><td>:</td><td><font color=DarkBlue>%@</font></td></tr>", currentKey,[resDict objectForKey:currentKey]];

        }
        [htmlString appendString:endString];
        NSString *cssString=[NSString stringWithFormat:@"table { width:100%; font-size:12px;font-family:Verdana}"];

        NSString *htmlString1 = [NSString stringWithFormat:@"<html> <head>     <style type=\"text/css\"> %@ </style> </head> <body> %@ </body> </html>", cssString, htmlString];  

        [webView loadHTMLString:htmlString1 baseURL:nil];

        [webView.scrollView setBounces:NO];

    }
        return cell;

}

ありがとう

4

3 に答える 3

0

この単純なコードは、iOS7で機能します

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
    [web loadHTMLString:@"im a <b>webview</b>" baseURL:nil];
    web.userInteractionEnabled = NO;
    [cell.contentView addSubview:web];

    return cell;
}
于 2013-11-15T10:46:20.243 に答える
0

次のコードを置き換えてみてください

    NSString *htmlString1 = [NSString stringWithFormat:@"<html> <head>     <style type=\"text/css\"> %@ </style> </head> <body> %@ </body> </html>", cssString, htmlString];  

    NSString *htmlString1 = [NSString stringWithFormat:@"<html> <head>     <style> %@ </style> </head> <body> %@ </body> </html>", cssString, htmlString];  
于 2013-11-15T11:40:34.203 に答える