如何在ios上的uiwebview上交互javascript onClick事件

时间:2014-09-09 13:02:06

标签: ios objective-c uiwebview

当我点击它时,UIWebView有相机图标,我想显示window.JSInterface.slideshow()内的所有图像。但是如何在onClick上启用UIWebView事件(此处课程中有onClick相机图标)

我从服务中得到的字符串。

<style>
.rslides img 
{
 display: block; max-width: 98%; margin: 0 auto; min-height:160px; min-width:320px; background-image: url("http://apps.xxxxx.com/interface/api/assets/placeholder.png"); background-repeat:no-repeat;
 } 
.over
{
background-image: url("http://apps.xxxxxx.com/interface/api/assets/camera.png"); background-repeat:no-repeat; width:48px; height:48px; position: relative; left:20%; top:-50px; z-index:51;
}
</style>

<div class="rslides" onclick="window.JSInterface.slideshow('6383232',
 'http://xxxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094062g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094061g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094060g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094059g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094057g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094058g.jpg');">
<img src="http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094062g.jpg"/>
</div>
<div class="over" onclick="window.JSInterface.slideshow('6383232', 
'http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094062g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094061g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094060g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094059g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094057g.jpg,
http://xxxx.xxxxx.com/multimedia/dynamic/02094/Nanbenda_Movie_Sti_2094058g.jpg');">
</div>

1 个答案:

答案 0 :(得分:0)

  1. 在您的JS onclick函数中触发一个URL
  2. 在UIWebView的委托方法中中断URL调用 webView:shouldStartLoadWithRequest:navigationType: