相关疑难解决方法(0)

从WKWebView中的本机代码调用JavaScript函数

在iOS 8中使用WKWebView,如何从本机端运行JavaScript函数或以其他方式从本机端到JavaScript进行通信?似乎没有类似于UIWebView的方法stringByEvaluatingJavaScriptFromString:.

(我可以- addScriptMessageHandler:name:configuration.userContentController对象上使用以允许从JS到本地的通信,但我正在寻找相反的方向.)

javascript webkit ios wkwebview

46
推荐指数
3
解决办法
5万
查看次数

iOS:如何获得长按手势的持续时间?

我正在开发一种游戏,通过长按对象本身来设置游戏对象的属性.属性的值由长按手势的持续时间确定.我正在使用UILongPressGestureRecognizer来实现这个目的,所以它是这样的:

[gameObjectView addGestureRecognizer:[[UILongPressGestureRecognizer alloc] 
                                       initWithTarget:self action:@selector(handle:)]];
Run Code Online (Sandbox Code Playgroud)

然后是处理函数

- (void)handle:(UILongPressGestureRecognizer)gesture {
  if (gesture.state == UIGestureRecognizerStateEnded) {
    // Get the duration of the gesture and calculate the value for the attribute
  }
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,如何获得长按手势的持续时间?

uigesturerecognizer ios

17
推荐指数
3
解决办法
3万
查看次数

标签 统计

ios ×2

javascript ×1

uigesturerecognizer ×1

webkit ×1

wkwebview ×1