ModMyMotoModMyiModMyGphone





 
 

2.2 Unlock | Jailbreak OS X




  Apple Forums | ModMyi.com | iPhone, iPod, Mac, OS X, Mods, More > 3rd Party Apps For iPhone | iPod Touch > 3rd Party Apps Requests
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-08-2007, 04:24 PM
ReVan's Avatar
iPhoneaholic
 
Join Date: Oct 2007
Location: BOOTLOADER
Posts: 453
Thanks: 6
Thanked 516 Times in 107 Posts
iPhone Web Development Tips and Official Documentation Released

iPhone Web Development Tips and Official Documentation Released

As soon as the iPhone was in developers hands on Friday they were hacking around. This involved doing a "for (var key in document)" and the like to see what was available.

In an ideal world, Apple would have released a beautiful set of documentation for the community, but they were probably too busy getting the phone out of the door (maybe can't blame them huh).

The community has begun to document things:

Getting rid of the toolbar

You can scroll down a little, enough to get rid of the toolbar via:
Code:
javascript:

   1.
       
   2.
      window.onload = function() {
   3.
        setTimeout(function(){window.scrollTo(0, 1);}, 100);
   4.
      }
   5.
but what about handling the rotation of the phone?

Updating the Layout when the user rotates

Joe Hewitt built a liquid layout that watches the the change from portrait to landscape mode.
Code:
javascript:

   1.
       
   2.
      addEventListener("load", function()
   3.
      {
   4.
          setTimeout(updateLayout, 0);
   5.
      }, false);
   6.
       
   7.
      var currentWidth = 0;
   8.
       
   9.
      function updateLayout()
  10.
      {
  11.
          if (window.innerWidth != currentWidth)
  12.
          {
  13.
              currentWidth = window.innerWidth;
  14.
       
  15.
              var orient = currentWidth == 320 ? "profile" : "landscape";
  16.
              document.body.setAttribute("orient", orient);
  17.
              setTimeout(function()
  18.
              {
  19.
                  window.scrollTo(0, 1);
  20.
              }, 100);           
  21.
          }
  22.
      }
  23.
       
  24.
      setInterval(updateLayout, 400);
  25.
Notice that there isn't a nice event for "hey I just changed mode". Instead, we have to poll and check the current width.

meta viewport

There is also a lot of chat about the viewport tag, and people are experimenting with getting a nice outcome when jumping between the various modes. E.g.
Code:
HTML:

   1.
       
   2.
      <meta name="viewport" content="width=480; initial-scale=0.6666; maximum-scale=1.0; minimum-scale=0.6666" />
   3.
View Source

To do a lot of testing, it would help to be able to do a view source on other cool iPhone applications. this work, based on Abe's let's you.

Drag and drop

Everyone has been a bit frustrated with the lack of events, but between Tahoma Toelkes and Joe Hewitt, we have a drag demo that works when you do a two-finger vertical dragging motion on the phone, but only for certain elements such as textareas.

Then comes the official docs

After all of this tinkering, we finally get the official docs from Apple. They are a little sparse, and don't seem to have much new, but at least they are out there, and they are official.

It is here that you can learn:

* How Apple thinks you should specify an iPhone only set of style (mixed reviews on how IE handles this). The iPhone ignores the handheld profile as it thinks of itself as a desktop browser instead.
Code:
      HTML:
         1.
             
         2.
            <link media="only screen and (max-device-width: 480px)" href="iPhone.css" type="text/css" rel="stylesheet" />
         3.
* The various meta data for viewport:
o width The default is 980. The range is [200, 10,000].
o height The default is calculated based on the width and aspect ratio. The range is [223, 10,000].
o initial-scale is the scale to render the page when it first loads. The default fits the page to the screen. The range is [minimum-scale, maximum-scale]. Keep in mind that the user can change the scale, either through the pinch gesture or by a double tap.
o user-scalable determines whether or not the user can scale the page. The default is yes.
o minimum-scale is the lower bound for scaling. The default is 0.25; the range is [>0, 10].
o maximum-scale is the upper bound for scaling. The default is 1.6; the range is [>0, 10].
* How to interact with the apps from JavaScript
o Phone call: <a href="tel:1-408-555-5555">1-408-555-5555</a>
o Mail: <a href="mailto:frank@wwdcdemo.example.com">John Frank</a>
o Google Maps: <a href="http://maps.google.com/maps?q=cupertino">Cupertino</a>
* How to embed a movie in a page (making sure to setup a preview image)
* Making sure your text is readable
* And much more.

The documentation states that Safari for iPhone is your good old Safari, however there seem to be a LOT of differences in practice, and it has been said that the codebase was forked some time ago.

More information on iPhone Development

I recommend hanging out on the iPhoneWebDev group, and we are excited to have Joe Hewitt himself speak at The Ajax Experience in a few weeks, all about his experience with the iPhone, and what he has learnt.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following 2 Users Say Thank You to ReVan For This Useful Post:
blue_wind (10-09-2007), Happylinks (09-02-2008)
Reply

  Apple Forums | ModMyi.com | iPhone, iPod, Mac, OS X, Mods, More > 3rd Party Apps For iPhone | iPod Touch > 3rd Party Apps Requests

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Go to Top
ModMyI

All times are GMT -6. The time now is 02:34 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 | Dedicated Server Hosting by SingleHop | Copyright © 2007-08 by ModMy, LLC. All rights reserved.

RSS - Contact Us / / ModMyi Home / Archive / Privacy Statement - Top
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316