`

iPhone开发注意事项

阅读更多

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()
   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. 缩放与META标签 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. iPhone应用集成 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. 了解iPhone的User-Agent头 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. 了解iPhone参数 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.

分享到:
评论

相关推荐

    iPhone开发教程之iPhone内存释放注意事项两则--千锋培训

    ### iPhone开发教程之iPhone内存释放注意事项两则 #### 内存管理基础知识 在iOS开发过程中,内存管理是一项非常重要的任务。对于iOS应用来说,如果内存管理不当,可能会导致程序崩溃或者被系统强制关闭。在...

    手机开发注意事项

    以下是对这些注意事项的详细解释: 首先,产品说明是吸引用户的关键。一个清晰、突出优势的产品描述能瞬间抓住用户的眼球,促使他们下载并体验软件。产品说明应当简洁明了,突出软件的核心功能和独特之处,同时兼顾...

    零点起飞学iPhone开发随书源代码

    它可能强调了学习过程中的注意事项,比如如何有效使用源代码,是否允许将代码用于商业项目,以及如何避免常见的编程陷阱。 总结来说,《零点起飞学iPhone开发随书源代码》是一份全面的学习资源,它不仅提供了丰富的...

    iphone开发比较实用,object-c注意事项,能提高不少

    以下是一些关于Objective-C的实用知识点和注意事项,它们可以帮助你提升开发效率和代码质量。 1. **消息传递机制**:Objective-C的核心是消息传递,它通过“发送消息”给对象来执行操作。了解`-[receiver message]`...

    ios6 开发注意事项

    以下是一些关键的开发注意事项: 1. **屏幕大小适配**: 在iOS6中,设备屏幕大小的变化需要特别关注。不要直接使用硬编码的数值,如320/480来表示屏幕宽度和高度,因为这可能导致在不同尺寸的设备上出现问题。例如...

    iPhone 开发基础教程

    #### 五、注意事项 - **限制与审批**:由于iPhone是始终连接互联网的移动设备,苹果公司对开发者有一定的限制,主要是为了避免恶意或低效程序影响网络性能。同时,苹果公司也尽力简化开发流程。 - **实际设备测试**...

    iPhone开发相关资源

    #### 五、注意事项 - **文档准确性**: 尽管文档中声明苹果公司已尽力确保文档信息的准确性,但仍然存在可能的打字错误或信息过时的情况。 - **法律责任**: 开发者在使用文档的过程中需自行承担全部风险,苹果公司...

    iphone开发实战下部

    最后,本书还会介绍App Store的提交流程,包括应用的版本管理、隐私政策的制定、App审核的注意事项等,让开发者能够顺利发布自己的作品。 总的来说,《iPhone开发实战下部》全面覆盖了iOS开发的核心知识,通过丰富...

    官方提供的iPhone开发教程

    #### 五、其他注意事项 1. **商标**: 文档中列出了多个苹果公司的注册商标,如Apple、iPhone、MacOS等,以及一些第三方商标如Intel、Java等。这表明开发者在开发过程中需要注意不要侵犯这些商标权。 2. **法律责任*...

    iphone开发教程16

    8. **App Store发布流程**:可能涵盖了代码签名、版本控制、提交审核的步骤和注意事项。 每一部分都会通过实例项目来巩固理论知识,让学习者能够实际操作并理解所学内容。这样的教程对于自学者或初学者来说,是掌握...

    在虚拟机下搭建phonegap的iphone开发环境版本

    在虚拟机下搭建PhoneGap的iPhone开发环境是一个复杂但必要的过程,尤其对于那些没有实际苹果设备的开发者来说。PhoneGap是一种流行的开源框架,允许开发者使用HTML、CSS和JavaScript来构建跨平台的移动应用,包括iOS...

    iPhone开发指南(中-英文版)

    书中会详细介绍App Store的审核流程和提交应用的注意事项。 总而言之,《iPhone开发指南(中-英文版)》是一本全面覆盖iOS开发各个方面的教材,通过深入学习,开发者不仅可以掌握iPhone应用程序的开发技能,还能了解...

    iphone开发入门指导

    #### 四、注意事项 - **版权问题**: 如文中所述,“任何个人被授权仅将文档存储于一台计算机上供个人使用,并可打印文档供个人使用”。因此,在使用苹果提供的文档资料时,需要注意版权问题,避免违反相关规定。 - ...

Global site tag (gtag.js) - Google Analytics