我有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];
}
答案 0 :(得分:1)
数据由Web视图缓存。
将'ignore local data cachePolicy'传递给原来的NSURLRequest
(你最初调用loadRequest!)
NSMutableURLRequest *r = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"URL"]];
r.cachePolicy = NSURLRequestReloadIgnoringCacheData;
//load in webview
答案 1 :(得分:-1)
尝试
[wbCont stopLoading ];
[wbCont reload];