<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UECSS.COM &#187; wap</title>
	<atom:link href="http://uecss.com/tag/wap/feed" rel="self" type="application/rss+xml" />
	<link>http://uecss.com</link>
	<description>记录我们自己的前端生活!</description>
	<lastBuildDate>Sun, 29 Aug 2010 13:27:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>iphone/ipad网站开发技巧整理</title>
		<link>http://uecss.com/iphone-ipad-web-development-skills.html</link>
		<comments>http://uecss.com/iphone-ipad-web-development-skills.html#comments</comments>
		<pubDate>Sun, 06 Jun 2010 04:57:55 +0000</pubDate>
		<dc:creator>猪的明天</dc:creator>
				<category><![CDATA[懒得分类]]></category>
		<category><![CDATA[wap]]></category>

		<guid isPermaLink="false">http://uecss.com/?p=518</guid>
		<description><![CDATA[iphone/ipad异常刚猛，在此把收集到的一些开发技巧罗列出来,方便项目中参考使用,如下： 侦测iPhone/iPod 开发特定设备的移动网站，首先要做的就是设备侦测了。下面是使用Javascript侦测iPhone/iPod的UA，然后转向到专属的URL。 if((navigator.userAgent.match(/iPhone/i)) &#124;&#124; (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf(&#34;iphone_redirect=false&#34;) == -1) { window.location = &#34;http://m.example.com&#34;; } } 虽然Javascript是可以在水果设备上运行的，但是用户还是可以禁用。它也会造成客户端刷新和额外的数据传输，所以下面是服务器端侦测和转向： if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') &#124;&#124; strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) { header('Location: http://yoursite.com/iphone'); exit(); } 设置viewpoint和屏幕等宽 如果不设置viewpoint，网站在viewpoint就会显示成缩略形式。如果你专门为iPhone/iPod开发网站，这一条很有用，而且很简单，只需要插入到head里就可以： &#60;meta name=&#34;viewport&#34; content=&#34;width=device-width; initial-scale=1.0; maximum-scale=1.0;&#34;&#62; 使用iPhone规格图标 如果你的用户将你的网站添加到home screen，iPhone会使用网站的缩略图作为图标。然而你可以提供一个自己设计的图标，这样当然更好。图片是57×57大小，png格式。不需要自己做圆角和反光，系统会自动完成这些工作。然后将下面这条加入head中： &#60;rel=&#34;apple-touch-icon&#34; href=&#34;images/youricon.png&#34;/&#62; 阻止旋转屏幕时自动调整字体大小 -webkit-text-size-adjust是webkit的私有css： html, body, form, fieldset, p, div, h1, h2, h3, h4, h5, h6 {-webkit-text-size-adjust:none;} 侦测设备旋转方向 iPhone可以在横屏状态下浏览网页，有时候你会想知道用户设备的手持状态来增强可用性和功能。下面一段Javascript可以判断出设备向哪个方向旋转，并且替换css：]]></description>
			<content:encoded><![CDATA[<p><a href="http://uecss.com/wp-content/uploads/2010/06/apple-iphone-ipad-300x274.jpg"><img src="http://uecss.com/wp-content/uploads/2010/06/apple-iphone-ipad-300x274.jpg" alt="" title="apple-iphone-ipad" width="300" height="274" class="aligncenter size-full wp-image-528" /></a><br />
<b>iphone/ipad</b>异常刚猛，在此把收集到的一些开发技巧罗列出来,方便项目中参考使用,如下：</p>
<p><strong>侦测iPhone/iPod</strong></p>
<p>开发特定设备的移动网站，首先要做的就是设备侦测了。下面是使用Javascript侦测iPhone/iPod的UA，然后转向到专属的URL。</p>
<pre class="brush: jscript;">
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
if (document.cookie.indexOf(&quot;iphone_redirect=false&quot;) == -1) {
window.location = &quot;http://m.example.com&quot;;
}
}
</pre>
<p>虽然Javascript是可以在水果设备上运行的，但是用户还是可以禁用。它也会造成客户端刷新和额外的数据传输，所以下面是服务器端侦测和转向：</p>
<pre class="brush: jscript;">
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) {
header('Location: http://yoursite.com/iphone');
exit();
}
</pre>
<p><strong>设置viewpoint和屏幕等宽</strong></p>
<p>如果不设置viewpoint，网站在viewpoint就会显示成缩略形式。如果你专门为iPhone/iPod开发网站，这一条很有用，而且很简单，只需要插入到head里就可以：<span id="more-518"></span></p>
<pre class="brush: xml;">
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width; initial-scale=1.0; maximum-scale=1.0;&quot;&gt;
</pre>
<p><strong>使用iPhone规格图标</strong></p>
<p>如果你的用户将你的网站添加到home screen，iPhone会使用网站的缩略图作为图标。然而你可以提供一个自己设计的图标，这样当然更好。图片是57×57大小，png格式。不需要自己做圆角和反光，系统会自动完成这些工作。然后将下面这条加入head中：</p>
<pre class="brush: xml;">
&lt;rel=&quot;apple-touch-icon&quot; href=&quot;images/youricon.png&quot;/&gt;
</pre>
<p><strong>阻止旋转屏幕时自动调整字体大小</strong></p>
<p>-webkit-text-size-adjust是webkit的私有css：</p>
<pre class="brush: css;">
html, body, form, fieldset, p, div, h1, h2, h3, h4, h5, h6 {-webkit-text-size-adjust:none;}
</pre>
<p><strong>侦测设备旋转方向</strong></p>
<p>iPhone可以在横屏状态下浏览网页，有时候你会想知道用户设备的手持状态来增强可用性和功能。下面一段Javascript可以判断出设备向哪个方向旋转，并且替换css：</p>
<pre class="brush: jscript;">
window.onload = function initialLoad() {updateOrientation();}

function updateOrientation(){
var contentType = “show_”;
switch(window.orientation){
case 0:
contentType += “normal”;
break;

case -90:
contentType += “right”;
break;

case 90:
contentType += “left”;
break;

case 180:
contentType += “flipped”;
break;
}
document.getElementById(“page_wrapper”).setAttribute(“class”, contentType);
}
</pre>
<p><strong>iPhone才识别的CSS</strong></p>
<p>如果不想设备侦测，可以用CSS媒体查询来专为iPhone/iPod定义样式。</p>
<pre class="brush: css;">
@media screen and (max-device-width: 480px) {}
</pre>
<p><strong>缩小图片</strong></p>
<p>网站的大图通常宽度都超过480像素，如果用前面的代码限制了缩放，这些图片在iPhone版显示显然会超过屏幕。好在iPhone机能还够，我们可以用CSS让iPhone自动将大图片缩小显示。</p>
<pre class="brush: css;">
@media screen and (max-device-width: 480px){
img{max-width:100%;height:auto;}
}
</pre>
<p>注意如果原图片非常大，或一个页面非常多图，最好还是在服务器端缩放到480像素宽，iPhone只需要在正常浏览时缩略到320像素。这样不会消耗太多流量和机能。</p>
<p><strong>默认隐藏工具栏</strong></p>
<p>iPhone的浏览器工具栏会在页面最顶端，卷动网页后才隐藏。这样在加载网页完成后显得很浪费空间，特别是横向屏幕时。我们可以让它自动卷动上去。</p>
<pre class="brush: jscript;">
window.addEventListener('load', function() {
setTimeout(scrollTo, 0, 0, 1);
}, false);
</pre>
<p><strong>使用特殊链接</strong></p>
<p>这两条不用说了吧：</p>
<pre class="brush: xml;">
&lt;a href=&quot;tel:12345654321&quot;&gt;打电话给我&lt;/a&gt;
&lt;a href=&quot;sms:12345654321&quot;&gt;发短信&lt;/a&gt;
</pre>
<p><strong>模拟:hover伪类</strong></p>
<p>因为iPhone并没有鼠标指针，所以没有hover事件。那么CSS :hover伪类就没用了。但是iPhone有Touch事件，onTouchStart 类似 onMouseOver，onTouchEnd 类似 onMouseOut。所以我们可以用它来模拟hover。使用Javascript：</p>
<pre class="brush: jscript;">
var myLinks = document.getElementsByTagName('a');
for(var i = 0; i &lt; myLinks.length; i++){
myLinks[i].addEventListener(’touchstart’, function(){this.className = “hover”;}, false);
myLinks[i].addEventListener(’touchend’, function(){this.className = “”;}, false);
}
</pre>
<p>然后用CSS增加hover效果：</p>
<pre class="brush: css;">
a:hover, a.hover { /* 你的hover效果 */ }
</pre>
<p>这样设计一个链接，感觉可以更像按钮。并且，这个模拟可以用在任何元素上。</p>
<p><strong>iphone fixed positioning</strong></p>
<p>关于漂浮定位，测试后发现 <b>{</b> position: fixed; <b>}</b> 不能为其用，<br />
可以改为 <b>{</b> position:absolute; <b>}</b> 来实现，可以使用iphone看下<a href="http://uecss.com/demo/jeff/iphone-fixed-positioning/">DEMO：iphone-fixed-positioning</a></p>
<p>参考资料：</p>
<p><a rel="nofollow" href="http://csswizardry.com/2010/01/iphone-css-tips-for-building-iphone-websites/">iPhone CSS—tips for building iPhone websites</a></p>
<p><a rel="nofollow" href="http://davidwalsh.name/detect-iphone">iPhone &#038; iPod Detection Using Javascript</a></p>
<p><a rel="nofollow" href="http://articles.sitepoint.com/article/iphone-development-12-tips/">iPhone Development: 12 Tips To Get You Started</a></p>
<p><a href="http://www.engageinteractive.co.uk/blog/2008/06/19/tutorial-building-a-website-for-the-iphone/">Tutorial: Building a website for the iPhone</a></p>
<p><a rel="nofollow" href="http://www.evotech.net/blog/2008/12/hover-pseudoclass-for-the-iphone/">hover pseudoclass for the iPhone</a></p>
<p><a rel="nofollow" href="http://doctyper.com/archives/200808/fixed-positioning-on-mobile-safari/">fixed-positioning-on-mobile-safari</a></p>
<p><a rel="nofollow" href="http://developer.apple.com/safari/library/technotes/tn2010/tn2262/index.html">Preparing Your Web Content for iPad</a></p>
]]></content:encoded>
			<wfw:commentRss>http://uecss.com/iphone-ipad-web-development-skills.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPtouch iPhone Theme</title>
		<link>http://uecss.com/wptouch-iphone-theme.html</link>
		<comments>http://uecss.com/wptouch-iphone-theme.html#comments</comments>
		<pubDate>Sun, 31 Jan 2010 12:23:03 +0000</pubDate>
		<dc:creator>猪的明天</dc:creator>
				<category><![CDATA[懒得分类]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wap]]></category>

		<guid isPermaLink="false">http://uecss.com/?p=149</guid>
		<description><![CDATA[WPtouch iPhone Theme这款wp插件是专门为iPhone或iPod Touch用户而开发的，新的界面主题，兼容性良好，用你的iphone iPod Touch 这些玩意儿访问本站 （手机浏览器输入UECSS.COM）即可，下图是俺的水货iphone截屏快照（home+锁屏键）： 附上官方下载地址：点击这里进入下载页面]]></description>
			<content:encoded><![CDATA[<p><strong>WPtouch iPhone Theme</strong>这款wp插件是专门为iPhone或iPod Touch用户而开发的，新的界面主题，兼容性良好，用你的iphone iPod Touch 这些玩意儿访问本站 （手机浏览器输入<a href="http://uecss.com/">UECSS.COM</a>）即可，下图是俺的水货iphone截屏快照（home+锁屏键）：<br />
<img class="alignnone size-full wp-image-150" src="http://uecss.com/wp-content/uploads/2010/01/照片.jpg" alt="" width="320" height="480" /></p>
<p>附上官方下载地址：<a href="http://wordpress.org/extend/plugins/wptouch/">点击这里进入下载页面</a></p>
]]></content:encoded>
			<wfw:commentRss>http://uecss.com/wptouch-iphone-theme.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
