`
sp42
  • 浏览: 147304 次
  • 来自: Canton
文章分类
社区版块
存档分类
最新评论

在Apple iPhone上开发web注意的十件事

阅读更多
实质上就是手机的Ajax开发,相比我们熟悉的浏览器开发环境,iphone上做开发还要注意下列几项:
(希望这些经验能顺利跨平台的...好比webkit跑的在nokia上也八九不离个十)

10 must-know guidelines for iphone web app developers
August 31, 2007, 12:21 pm  tagged: css html iphone javascript programming

I visited iPhone Tech Talks on 30th of August.  Initially I wasn't thrilled about it and didn't have much expectation .  However, I found the show to be very informative and fun.  I got to seat and chat with many developers who are actively working on lots of cool iPhone apps and services.

In the beginning of the show, they mentioned that we are in bidirectional NDA (Non Disclosure Agreement) contract.  I do not see any secretive information from Apple or iPhone's prospective, but Some developers had some interesting ideas which I'm not going to disclose.

There were bast information given in 5 hours lecture - from Developer's scenario to optimizing for iPhone and how iPhone's safari renders web pages. I tried to gather most of the valuable information and organized in category of guidelines.  Hope these helps!!

   1. Separation of contents:  
         1. Put all JavaScript on .js file and all styles on separate .css file. 
         2. Obvious explanation is for better coding and readability, but main advantage is that - this design practice improves loading speed on iPhone, specially on edge network.  This is because safari caches all css and js files when they are separate.
   2. Use Standards: 
         1. iPhone supports following standards: HTML 4.01, XHTML 1.0, DOM, CSS 2.1, some CS3, Javascript Ecmascript 3. 
         2. Does not support WML. 
         3. My tip, which they didn't mention but I think is good practice, is to use XHTML 1.0 Strict rules instead of HTML 4.01 and XHTML 1.0 Transitional.  This ensure most compatibility and speed of browser for rendering.
   3. Know the limitations:
         1. Resource limitations:
               1. 10MB for each text based files (each html, js, css).  This is huge, so I don't actually consider as limitation.
               2. 8MB for images such as tiff, gif, png
               3. 32MB for jpeg images.
               4. 2MB of animated gif. If the animated gif is larger, iPhone will simply show the first frame and won't animate.
               5. if a page is greater then 10MB, it may load, but would cut resources from any other open window, if available.
         2. Javascript limitations:
               1. as I mentioned 10MB file size.
               2. only 5 second of execute.  This is to ensure a script does not make the iPhone non responsive. 
                     1. If the execute time is greater, it will through Exception.
                     2. So put it on try catch block.
               3. Know that script maybe paused.  So when window is inactive your script is paused.  So javascript timer will not show accurate time when user leaves the safari or goes to different window.
         3. Plug-in limitations:
               1. No Java
               2. No Flash
               3. no SVG
         4. File System
               1. NO File System
               2. Upload button will be disabled and grayed out.
   4. Know what is supported:
         1. Most of javascript functions, events are supported:
               1. window.open, target="_new", alert(), confirm(), prompt()
                     1. even though alert, confirm and prompt are a bad way to send or receive information from users in real desktop browser, iPhone it's totally different case.  In fact it is encouraged.  The script window looks good and sexy.  Feels like real app window.
               2. Events:
                     1. tap triggers onclick, onmousedown, onmouseup and onmousemove
                     2. two finger triggers mousewheel
                     3. all other events such as blur, focus, load, unload, reset, submit, change, abort are supported
                     4. please note that you can not call blur or focus events using javascript.  But events will be fired when these events happens.
         2. Supported Files within web browser:
               1. Excel. Nicely converts to html and put separate sheets as tabs.
               2. Word.
               3. PDF. Does not support password protected files.
               4. Quicktime audio and video:
                     1. H.264 base 2, 640x480 at 30fps
                           1. Does NOT support B frames
                     1. AAC-LC upto 48kHz
                     2. mov, mp4, m4v, 3gp
                     3. mpeg-4 part 2
               5. Canvas for animation and data driven content
                     1. Canvas is now Standard
                     2. Used to create all Mac OS Widget
                     3. now supported by Opera, Firefox
                     4. iPhone uses complete implementation
                     5. iPhone's stock uses Canvas to animate and show data
         3. Built-in Fonts
               1. Ariel, Courier, Georgia, Trebuchet, Zapfino,Helvetica, Times, Verdana
   5. Scaling/Zooming and META tag:
         1. iPhone will scale a web page to 980x1091 first, then scale back to 320x480.  They use this technique for all web sites.
         2. iPhone looks for following meta tags for overriding default scaling:
               1. <meta name="viewport" content="width=320">
                     1. this will not scale at all and just render the page to 320 width
               2. <meta name="viewport" content="initial-scale=1">
                     1. initial-scale = 1 means 100%, 2 means 200% and so on.
               3. other values for contents
                     1. user-scalable=yes/no
                           1. if set to no, user can't pinch or zoom
                     2. minimum-scale or maximum-scale
         3. Control zooming on every element of the HTML page
               1. use -webkit-text-size-adjust property to control zooming by double tapping to all html elements including div, table, body.
                     1. -webki-text-size-adjust has following values:
                           1. none: disable zooming
                           2. auto: let Safari handle it
                           3. %: set to a percentage
   6. Integrate with iPhone's app
         1. integrate with Google Map Application
               1. simply like using anchor with <a href="/map?q=pizza+10018">show me pizza!</a>
               2. q parameter is for terms
         2. integrate with Phone App
               1. <a href="tel:+1(800)222-2222">call us</a>
         3. integrate with Mail App
               1. <a href="mailto:me@mydomain.com?subject=hello&message=this is a message">email me</a>
   7. Understand iPhone's User Agent
         1. iPhone User Agents has following terms
               1. iPhone;U;CPU like Mac OS X;en
               2. AppleWebKit/420 - gives WebKit version
               3. Version/3.0 -  3 for Safari 3 family
               4. Mobile/xxxx - iPhone Safari build number
               5. Safari
   8. Understand iPhone Safari's preference:
         1. This is important because developer needs to know that users can disable and enable some features from the iPhone's Setting.
               1. javascript can be turned off (on by default)
               2. pop-up block can be turned off
               3. cookies policy can be changed just like desktop Safari
   9. MISC. Tips:
         1. create rounded rectangle:
               1. user -webkit-border-radius css property to create nice rounded rectangle.
         2. create button or header
               1. user -webkit-border-image to create nice headers and buttons
         3. user javascript frameworks
               1. iUi (praised by the staffs)
               2. YUI (Yahoo library)
               3. dojo
               4. prototype
               5. JQuery
         4. use CS3 media query to detect iPhone when including css files
               1. iPhone returns "screen" and width value
         5. turn on server-side compression
               1. this alone can save up-to 50% of download time.
  10. DEBUGGING
         1. Turn on developer's menu for safari,learn how.
         2. Download nightly build Webkit which includes excellent and extended "Inspect Element" tool.  http://webkit.org/
         3. User Drosera (comes with nightly build webkit for only for Mac)  for debugging Javascript.

转帖 :http://alaminahmed.com/?id=10_mustknow_guidelines_for_iphone_web_app_developers
分享到:
评论
2 楼 KorbenZhang 2008-06-11  
醒醒,天亮了
1 楼 afcn0 2007-12-16  
送我一个iphone,我就去研究iphone怎么开发,iphone是很cool的呀

相关推荐

    apple watch 与Iphone怎么配对连接?.docx

    3. 在 Apple Watch 上轻按“开始配对”,同时在 iPhone 上轻按“开始配对”。 4. 把 iPhone 置于 Apple Watch 的配对动画上方。 5. 等待 Apple Watch 和 iPhone 完成配对,直到出现提示“Apple Watch 已配对”。 6. ...

    iPhone的web开发框架 UiUIKit

    1. **响应式设计**:由于UiUIKit是为iPhone设计的,因此在开发过程中,需要考虑不同型号iPhone的屏幕尺寸和分辨率,确保应用能在所有设备上正常显示。 2. **性能优化**:尽管CSS3和JavaScript能带来丰富的视觉效果,...

    Apple Watch开发快速入门教程

    综上所述,Apple Watch开发快速入门涉及的知识点广泛且深入,从基础的Swift语言到复杂的WatchKit框架和WatchConnectivity通信,再到健康数据的集成和App Store的发布流程,每个环节都需要开发者精心研究和实践。...

    用Eclipse 开发 iPhone Web 应用程序(doc)

    对于iOS设备,尤其是iPhone而言,虽然原生应用开发通常采用Swift或Objective-C语言,但在某些场景下,开发基于Web技术的应用也能满足需求,且具有跨平台的优势。本文将详细介绍如何使用Eclipse这一流行IDE来构建适用...

    iPhone开发基础教程电子书

    首先,对于一个完全没有mac开发经验,甚至从没摸过苹果系统的开发人员来说,首先就是要熟悉apple的那一套开发框架(含开发环境IDE、开发框架uikit,还有开发语言objective-c)。对于有一定编程经验的人来说,学习...

    Apple iPhone 6 and iPhone 6 Plus MOCKUP PSD

    标题 "Apple iPhone 6 and iPhone 6 Plus MOCKUP PSD" 提供了我们即将讨论的核心内容:这是一套针对苹果iPhone 6和iPhone 6 Plus设计的模拟展示(mockup)资源,采用PSD(Photoshop Document)格式。Mockup工具在UI/...

    iPhone开发实战.pdf

    - **模拟器与真机测试**: 在开发过程中,开发者可以使用Xcode自带的模拟器来进行初步测试,之后还可以在真实的iPhone设备上进行更详尽的测试以确保应用的稳定性和兼容性。 ### 二、关键技术点 #### 2.1 UIKit框架 ...

    iPhone开发环境搭建

    【iPhone开发环境搭建】 搭建iPhone开发环境是iOS应用开发的第一步,主要涉及到在特定的操作系统环境下安装必要的...在开发过程中,保持对Apple开发者文档和社区资源的持续关注,以便获取最新的技术信息和解决方案。

    Apple Watch开发快速入门教程试读

    WatchKit框架使得开发者能够创建专门针对Apple Watch的应用程序,或为现有的iPhone应用程序开发配套的Watch版本。本教程提供了全面的WatchKit学习资料,旨在帮助读者快速掌握Apple Watch的应用开发。 开发Apple ...

    Beginning iPhone and iPad Web Apps

    《初识iPhone与iPad Web应用开发》是一本专注于在苹果移动设备上构建Web应用程序的入门指南。本书旨在帮助读者理解并掌握如何利用Web技术,如HTML、CSS和JavaScript,为iPhone和iPad用户创建功能丰富的、优化的Web...

    iphone游戏开发实践指南 源代码

    《iPhone游戏开发实践指南》是一本深入探讨iPhone游戏开发的专业书籍,它涵盖了从基础到高级的游戏开发技术。这本书的源代码提供了丰富的实例,帮助开发者更好地理解游戏开发过程中的各种概念和技巧。通过阅读和分析...

    计算器 iphone下开发的。 xcode

    在iOS平台上开发应用程序,开发者通常会利用Apple提供的集成开发环境(IDE)——Xcode。本项目是针对iPhone设备创建的一个计算器应用,它展示了如何在Xcode中进行移动应用的开发流程。Xcode集成了代码编辑器、界面...

    轻松学iPhone开发

    此外,书中会讲解如何使用iPhone Simulator,这是一个强大的工具,开发者可以不用真机就能测试应用在不同iOS版本和设备上的表现。 第二篇可能涉及实际编程概念,如Objective-C或Swift语言基础,这是编写iOS应用的...

    Apple+iPhone拆解分析

    综上所述,Apple iPhone 不仅在硬件配置和技术规格方面表现出色,而且通过独特的设计理念和强大的品牌效应,在市场上获得了广泛的认可。通过对iPhone的拆解分析,我们不仅能够深入了解其内部结构,还能更好地理解其...

    Apple iPhone Tech Talk Notes

    因此,为了确保应用或网站在iPhone上的兼容性,开发者需要特别注意以下几点: 1. **用户可以设置浏览器偏好**:例如启用或禁用JavaScript、弹出窗口及保守的Cookie策略。 2. **分离页面内容**:将JavaScript、CSS和...

    iPhone WebApp 开发指南

    《iPhone WebApp 开发指南》是一本专注于指导开发者如何创建高效、流畅且具有原生体验的Web应用程序的著作。在iOS平台上,WebApp是一种利用移动Safari浏览器的特性,通过HTML5、CSS3和JavaScript技术构建的应用程序...

    在Windows中安装iPhone开发环境

    请注意,虽然这个过程可以在理论上实现,但Apple的开发者协议可能禁止在非Apple硬件上使用其开发工具。此外,这种方法可能存在兼容性问题和性能限制,因为虚拟化的macOS可能无法充分利用硬件资源,且可能受到Apple...

Global site tag (gtag.js) - Google Analytics