2011-10-19 94 views
3

我仍在學習jQuery mobile的技巧,並且在數據角色=「頁面」上放大和縮小圖片/圖像時遇到問題。有沒有辦法使用jquery mobile在iPhone上對圖像進行捏放/縮放工作?無法讓它在iOS模擬器上運行。這是我的代碼。如何在圖像上進行捏放/縮放工作

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>jQuery Mobile Web App</title> 

<meta content="width=device-width, initial-scale=1, maximum-scale=2" name="viewport"> 

<link href="jquery.mobile-1.0a3.min.css" rel="stylesheet" type="text/css"/> 
<script src="jquery-1.5.min.js" type="text/javascript"></script> 
<script src="jquery.mobile-1.0a3.min.js" type="text/javascript"></script> 
<!-- This reference to phonegap.js will allow for code hints as long as the current site  has been configured as a mobile application. 
To configure the site as a mobile application, go to Site -> Mobile Applications ->  Configure Application Framework... --> 
<script src="/phonegap.js" type="text/javascript"></script> 
</head> 
<body> 

    <div data-role="page" id="page"> 
    <div data-role="header"> 
    <h1>Page One</h1> 
    </div> 
    <div data-role="content" style="padding:0;">  
      <img src="coffee.gif" width="320" height="480" alt="coffee"> 
     </div> 
    <div data-role="footer"> 
    <h4>Page Footer</h4> 
    </div> 
    </div> 
</body> 
</html> 

非常感謝您的幫助。非常感激。

-bob

回答

3

這是控制這些設置的視口元數據屬性。

Follow this查看如何在JQM iOS上啓用縮放&縮放(應該不會影響您使用PhoneGap)。

希望這會有所幫助。

當jQuery Mobile呈現頁面時,它會將以下元標記添加到 文檔的頭部。

<meta content="width=device-width, minimum-scale=1, maximum-scale=1" name="viewport"> 

它是最小規模= 1,最大尺度= 1周的 它禁用捏放大的標籤的一部分。我們需要做的是修改 $ .mobile.metaViewportContent變量。我們可以使用下面的代碼 來做到這一點。

$(document).bind('mobileinit', function(){ 
    $.mobile.metaViewportContent = 'width=device-width'; 
}); 

如果我們想限制縮放量,我們可以使用以下命令:

$(document).bind('mobileinit', function(){ 
    $.mobile.metaViewportContent = 'width=device-width, minimum-scale=1, maximum-scale=2'; 
}); 
3

編輯在meta標籤的 「視口」 這個

<meta name="viewport" content="user-scalable=yes, initial-scale=1, maximum-scale=2, minimum-scale=0.5, width=device-width, height=device-height, target-densitydpi=device-dpi" />