아이폰의 uiwebview를 방문 할 때 누구나 자바 스크립트에서 방향 변경 이벤트를 처리하는 방법을 알려줄 수 있습니까?uiwebview에서 javacript onorientationchange 이벤트를 처리하는 방법
나는 onorientationchange
이벤트를 캡처하려고합니다. 나는 다음과 같은 코드를 시도했다.
<style type="text/css" media="only screen and (max-device-width: 480px)">
.portrait
{
width: 300px;
padding: 0 15px 0 5px;
}
.landscape
{
width: 460px;
padding: 0 15px 0 5px;
}
</style>
<script type="text/javascript">
window.onload = orientationchange;
window.onorientationchange = orientationchange;
function orientationchange() {
if (window.orientation == 90
|| window.orientation == -90) {
document.getElementById('contents').className = 'landscape';
}
else {
document.getElementById('contents').className = 'portrait';
}
}
</script>
// and I have a div inside html
<div id="contents">
my contents and description... e.t.c, and e.t.c...
</div>
그것은 사파리에서 잘 작동하지만 방문 할 때 방향 변경 이벤트를있는 UIWebView 사용하여 페이지가 포착되지 않고 내 원하는 기능이 acheived하지 않을 수 있습니다.
내가 필요가 없습니다 귀하의 웹보기를 호출 할 수 있습니다 로컬 리소스, 난 그냥 내 HTML의 자바 스크립트에서 오리 엔테이션 변경 이벤트를 캡처하고 싶습니다 –
내가 실패한 당신을 보여 주려고 게시물에서 인용문을 추가했습니다. 실제로 당신이 진술 한 문제입니다. –
예 감사합니다; 내 문제가 해결되었습니다. 그러나 응용 프로그램에서 방향이 설정된 html 페이지를 사용하는 것은 이상합니다. –