【问题标题】:Reload UIWebView重新加载 UIWebView
【发布时间】:2013-11-23 00:47:58
【问题描述】:

我有 UIWebView 用于显示文章。我将触摸位置坐标存储在数据库中并显示按钮。在我从数据库中删除坐标后,按钮仍然显示。当我从 UIWebView 返回并返回时,按钮正在移除。删除按钮后我需要重新加载或刷新。我用了Reload,但删除后显示白页。

-(void)recycle:(id)sender {


    int new_delete_tag;



    NSArray *coorpaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
    NSString *coordocumentsDirectory = [coorpaths objectAtIndex:0];
    NSLog(@"docs dir is %@", coordocumentsDirectory);

    NSString *coorpath = [coordocumentsDirectory stringByAppendingPathComponent:@"db.sqlite"];
    NSLog(@"filepath %@",coorpath);

    if (sqlite3_open([coorpath UTF8String], &database) == SQLITE_OK) {


        const char *sql =  [[NSString stringWithFormat:
                             @"SELECT xcoor,ycoor,artt_id,button_tag FROM touch where button_tag = '%d'", webbuttontag]cStringUsingEncoding:NSUTF8StringEncoding];


        NSLog(@"getmainsql is %s",sql);

        sqlite3_stmt *statement;

        if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
            // We "step" through the results - once for each row.
            while (sqlite3_step(statement) == SQLITE_ROW) {



                xfr=sqlite3_column_double(statement, 0);

                yfr=sqlite3_column_double(statement, 1);

                art_Idr = sqlite3_column_int(statement, 2);

                new_delete_tag = sqlite3_column_int(statement, 3);



                NSLog(@"xfr is %f",xfr);

                NSLog(@"yfr is %f",yfr);

                //  NSLog(@"zc is %@",zc);

                NSLog(@"art_Idr is %ld",(long)art_Idr);



                             NSLog(@"new_delete_tag is %d",new_delete_tag);



            }
        }
    }


    if(xfr && yfr && new_delete_tag && art_Idr){



        NSLog(@"error");


        NSLog(@"xfr is %f",xfr);
        NSLog(@"yfr is %f",yfr);
        NSLog(@"art_idd is %ld",(long)art_Idr);

        sqlite3_stmt *addStmt;




        const char *sqlDelete = [[NSString stringWithFormat:@"delete FROM touch where xcoor = %f AND ycoor = %f  AND button_tag = '%d' AND artt_id = '%@'",xfr,yfr,new_delete_tag,artID] cStringUsingEncoding:NSUTF8StringEncoding];


        NSLog(@"sql delete is %s",sqlDelete);

        if(sqlite3_prepare_v2(database, sqlDelete, -1, &addStmt, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while deleting coor from touch . '%s'", sqlite3_errmsg(database));

        NSLog(@"%s error finalizing %s", __FUNCTION__, sqlite3_errmsg(database));

        if(SQLITE_DONE != sqlite3_step(addStmt))
            NSAssert1(0, @"Error while deleting coor from touch . '%s'", sqlite3_errmsg(database));


    [txtview removeFromSuperview];


    }

  // Reload here  

[wbCont  reload];

}

【问题讨论】:

    标签: ios objective-c uiwebview reload


    【解决方案1】:

    数据由网络视图缓存。

    将“忽略本地数据缓存策略”传递给原始 NSURLRequest

    (您最初调用 loadRequest 的地方!)

    NSMutableURLRequest *r = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"URL"]];
    r.cachePolicy = NSURLRequestReloadIgnoringCacheData;
    //load in webview
    

    【讨论】:

      【解决方案2】:

      试试

      [wbCont  stopLoading ];
      [wbCont  reload];
      

      【讨论】:

      • 这里的逻辑是什么 :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-22
      • 2017-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多