当在 UIWebView 上长按时,我正在显示 UIMenuController menuitem 以进行点击操作。我有一个关于 UIMenuItem 的注释。当我单击注释时,我需要将位置坐标存储到数据库中。在我使用 UILongPressGesture 将坐标值存储到数据库之前。但它正在工作。为什么 UIMenuItem 操作不起作用?
- (void)note:(id)sender {
NSLog(@"Note");
// UILongPressGestureRecognizer *sn=(UILongPressGestureRecognizer *)sender;
xcor = [sender locationInView:wbCont.scrollView].x;
ycor = [sender locationInView:wbCont.scrollView].y;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"db.sqlite"];
NSLog(@"filepath %@",path);
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
const char *sql = [[NSString stringWithFormat:@"SELECT xcoor FROM touch where xcoor = '%f' AND ycoor = '%f' AND artt_id='%@'",xcor,ycor,artID] cStringUsingEncoding:NSUTF8StringEncoding];
NSLog(@"sql is %s",sql);
BOOL favExist = false;
sqlite3_stmt *statement, *addStmt;
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) {
favExist = true;
}
}
if(!favExist){
//Changes
universal_button_tag = arc4random() % 99;
NSLog(@"Universal Button tag: %d",universal_button_tag);
const char *sqlInsert = [[NSString stringWithFormat:@"insert into touch (xcoor,ycoor,artt_id,button_tag) values ('%f','%f','%@','%d')", xcor,ycor,artID,universal_button_tag] cStringUsingEncoding:NSUTF8StringEncoding];
//----
NSLog(@"sql insert is %s",sqlInsert);
// [catID release];
if(sqlite3_prepare_v2(database, sqlInsert, -1, &addStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
NSLog(@"error is %s",sqlite3_errmsg(database));
if(SQLITE_DONE != sqlite3_step(addStmt))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
}
}