我有 UIWebView 用于显示文章。我将触摸位置坐标存储在数据库中并显示按钮。在我从数据库中删除坐标后,按钮仍然显示。当我从 UIWebView 返回并返回时,按钮正在移除。删除按钮后我需要重新加载或刷新。我使用了重新加载,但删除后它显示白页。
-(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];
}