Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
tableview中的webview未在iOS 7中显示_Ios_Uitableview_Uiwebview - Fatal编程技术网

tableview中的webview未在iOS 7中显示

tableview中的webview未在iOS 7中显示,ios,uitableview,uiwebview,Ios,Uitableview,Uiwebview,在iOS 7中,tableview中的webview没有显示在哪里,因为它在iOS 5中工作正常。在iOS 7中,创建了一个示例应用程序,其中tableview中包含webview。它工作正常。搜索了很长时间后,我发现可能是由于手势识别器,tableview中的Webview没有显示出来。我在示例应用程序中测试了这个场景。但它很好用。因此,手势识别器没有问题 知道为什么tableview中的webview没有在iOS 7中显示吗 这是要检查的代码: - (NSInteger)numberOfSe

在iOS 7中,tableview中的webview没有显示在哪里,因为它在iOS 5中工作正常。在iOS 7中,创建了一个示例应用程序,其中tableview中包含webview。它工作正常。搜索了很长时间后,我发现可能是由于手势识别器,tableview中的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;

}
-(NSInteger)节数表视图:(UITableView*)表视图
{
返回[app.resultsDic count];
}
-(NSString*)表格视图:(UITableView*)表格视图标题标题标题部分:(NSInteger)部分
{
返回[NSString stringWithFormat:@“%d”,节];
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{   
返回1;
}
-(CGFloat)tableView:(UITableView*)表视图行高度索引路径:(NSIndexPath*)索引路径{
返回150;
}
-(UITableView单元格*)表格视图:(UITableView*)表格视图
cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“Cell”;
UIWebView*webView;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle重用标识符:CellIdentifier];
}
NSUTEGER行=[indexPath节];
如果([app.resultsDic count]>0)
{
NSArray*单元子视图=[单元子视图];
用于(单元子视图中的UIView*currSubView){
[当前子视图从SuperView移除];
}
webView=[[UIWebView alloc]initWithFrame:CGRectMake(15,8280140)];
webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage ImageName:@“bg.jpg”];
[单元添加子视图:网络视图];
//将数据检索到字典并使用htmlString格式化数据
NSDictionary*resDict=[app.resultsDic valueForKey:[NSString stringWithFormat:@“%d”,行]];
NSMutableString*htmlString=[[NSMutableString alloc]init];
NSString*initialString=[NSString stringWithFormat:@”“];
NSString*endString=[NSString stringWithFormat:@”“];
[htmlString appendString:initialString];
对于(int e=0;e<[resDict allKeys]计数];e++){
NSString*currentKey=[[resDict allKeys]objectAtIndex:e];
[htmlString appendFormat:@“%@:%@”,currentKey[resDict objectForKey:currentKey]];
}
[htmlString appendString:endString];
NSString*cssString=[NSString stringWithFormat:@“表格{宽度:100%;字体大小:12px;字体系列:Verdana}”;
NSString*htmlString1=[NSString stringWithFormat:@“%@%@”,cssString,htmlString];
[webView loadHTMLString:htmlString1 baseURL:nil];
[webView.scrollView setBounces:NO];
}
返回单元;
}

谢谢

这个简单的代码在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;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
UIWebView*web=[[UIWebView alloc]initWithFrame:CGRectMake(0,032100)];
[web loadHTMLString:@“我是网络视图”baseURL:nil];
web.userInteractionEnabled=否;
[cell.contentView addSubview:web];
返回单元;
}

能否尝试替换以下代码

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

NSString*htmlString1=[nsstringstringwithformat:@“%@%@”,cssString,htmlString];

table view中的webview在您正在每个单元格中加载web视图的意义上,对吗?用您的确切代码更新您的问题。除了所有其他版本的IOS 7之外,是否在所有网页中加载内容?是的,除了IOS 7之外,在所有网页中加载内容
    NSString *htmlString1 = [NSString stringWithFormat:@"<html> <head>     <style> %@ </style> </head> <body> %@ </body> </html>", cssString, htmlString];  
    I resolved this issue in iOS 7.

  //In ios 5, I have added this code for removing the subviews in webview.

      NSArray *cellSubviews = [cell subviews];

            for (UIView *currSubView in cellSubviews) 
            {
                [currSubView removeFromSuperview];
            }

    //In ios 7 , I have removed the above code. Because we need not to write any code for removing the subviews in webview.