A few days ago encountered problems, know the point of the screen, want to manipulate the corresponding content, record down, just a method, very superficial, deep research, there are a lot of problems to solve
//simulate a point on the screenCGFloat x = mains.width/2, y = mains.height/2-352; //js Get point element stringNSString *JSN = [NSString stringWithFormat:@"Document.elementfrompoint (%f,%f). TagName", x, y]; //get point corresponding node element name by loading JSNSString * TagName =[_webview STRINGBYEVALUATINGJAVASCRIPTFROMSTRING:JSN]; NSLog (@"%@", TagName); //a string that gets the corresponding element and operates on itNSString * Jsee = [NSString stringWithFormat:@"var obj = document.elementfrompoint (%f,%f), alert (obj), var event = {Clientx:%f,clienty:%f};obj.click (event)", X,y,x,y]; //loading strings to achieve the effect[_webview Stringbyevaluatingjavascriptfromstring:jsee];
iOS gets the js corresponding element by point coordinates