3 ms·
Development with the iPhone SDK - Initial Observations
- allenbrunson 17y agofrom the article: "The only shortcomings that I have noticed so far is that the simulator doesn't seem to respond to orientation changes of the iPhone simulator. There is a menu option to rotate the iPhone, but the orientation of the programs, even the built-in ones, doesn't change when the simulator rotates." I just tried this on my own iPhone simulator, and it's not true. The simulator's version of Safari does indeed rotate sideways when the simulator does.
- InkweaverReview 17y agoYou are correct. Safari does indeed rotate, but other applications such as Photo Album, etc don't. And it doesn't work on other Apple sample code programs either. Safari and Contacts seem to be the only two apps that rotate. Perhaps I just need to add the right code to my apps to make them rotate, but even the sample code applications from Apple don't rotate. I'm still looking into this issue. There has to be something that I'm missing.
- allenbrunson 17y agoas for "photo album:" are you sure that app rotates? My guess is that it doesn't, so obviously it won't on the simulator. Not every app rotates, remember. Until very recently, the only one of Apple's apps that did is Safari. I have gotten my own apps to rotate in the simulator just fine. You have to make that decision at the view controller level. Investigate the UIViewController method shouldAutorotateToInterfaceOrientation:
- ROFISH 17y agoIn addition, there's a Info.plist key/value, UIInterfaceOrientation with the value UIInterfaceOrientationLandscapeRight or UIInterfaceOrientationLandscapeLeft, that lets you set the default rotation level and the simulator will start the app in the correct rotation. EDIT: Also the autorotation only works on ViewControllers. If you only have Views without ViewControllers, (such as the default OpenGL app from the wizard) they will not rotate.
- InkweaverReview 17y agoWould I have to set up two views within Interface Builder, one for landscape and one for portrait, or do I use the one single view and rotate it using code?
- allenbrunson 17y agoyou just use one view. implement that view controller method i mentioned, and always return TRUE. you must do this for every view in your app, if you want them to all work in landscape modes. that's all you have to do, as far as the iphone is concerned. of course you'll have to draw the view contents differently, when you're in landscape mode.
- InkweaverReview 17y agoI'm going to look through the Apple sample code and see if I can find an example that changes orientation properly. So far none of the sample code apps that I have found rotate. Once I find one that does I'll be able to check the code and see how it is done.
- gcheong 17y agoThe Photo Album app does indeed rotate in the simulator, but only when you are viewing photos. The list of photo albums does not re-orient when rotated. This is how it works on actual hardware as well. Are you seeing something different? As an aside,in the 3.0 version of the simulator there is now an option for sending a shake gesture but in the one app I have that responds to shakes it didn't work no matter how low I set the threshold. Edit:looking at the shake gesture it seems that the method accelerometer:accelerometer didAccelerate does not get called (which is the method my app is using to detect shakes) when you send a shake gesture to the simulator so I'm not sure what the shake gesture actually does in 3.0.
- rob_rasmussen 17y agoThere's a new api for shake gestures in 3.0, your firstResponder needs to implement motion[Began|Cancelled|Ended]:withEvent. Works fine in the simulator.
- hboon 17y agoApps don't just rotate. You need to configure and most importantly code it so that they rotate. For example, notice that when Safari rotates, the navigation bar and toolbar height shrinks by half. That is done programmatically. It's not as easy as just setting a flag and the contents will rotate magically.
- yangyang 17y agoDoesn't really say a lot. Xcode is nice, there's a simulator, Interface Builder has lots of windows, and you need to program in Objective C. Nothing very insightful.
- InkweaverReview 17y agoThese are initial observations from the first day of using the iPhone SDK. Basically, I'm just sharing my first thoughts and impressions on the tools involved and how they work and appear. I'll share some insight later, after I explore the SDK and Objective C code interfaces in more detail.
- mitchellh 17y agoI always dislike "initial observation" posts because everyone seems to see things through rose-tinted glasses when they first come upon a new programming toy (or new programming tool). Its always more interesting to see the blog posts making observations after a person/company has released a serious project. This way, these people have been using the tools in their daily workflow for weeks/months and know most of the ins and outs of it.
- dkarl 17y agoPlus, with a free download like the iPhone SDK, it's more fun to get one's own first impressions than to read somebody else's.
- colinprince 17y agoI tried to comment on the story but it is broken. To the author: I think where you say "require that I learn an entirely new language" and go on to mention interfaces and handlers, you mean instead Cocoa (Cocoa Touch in this case) Nice write up and good luck