0

When longpress on UIWebView I am displaying UIMenuController menuitem for click action. I have a note on UIMenuItem. When I click the note I need to store location coordinates to database. Before I used UILongPressGesture for storing coordinate values to database. But it was working. Why the UIMenuItem action is not working?

- (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));


        }

    }
Daniel Larsson
  • 6,278
  • 5
  • 44
  • 82
user2967559
  • 97
  • 2
  • 13

1 Answers1

0

If I understand correctly you are using https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIMenuItem_Class/Reference/MenuItem.html that is subclass of NSObject and do not have methods locationInView (gestures have that method), so you got unrecognized selector

in.disee
  • 1,102
  • 1
  • 7
  • 15