当在UIWebView上进行longpress时,我正在显示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));
}
}
答案 0 :(得分:0)
如果我理解正确你使用的是https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIMenuItem_Class/Reference/MenuItem.html NSObject的子类并且没有方法locationInView(手势有那个方法),那么你就有了无法识别的选择器