This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
tutorials:automatically_update_the_screen_orientation [2012/07/31 19:38] – Fixed incorrect code 27.32.136.240 | tutorials:automatically_update_the_screen_orientation [2013/03/05 10:19] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Automatically update the screen orientation ====== | ||
+ | |||
+ | // | ||
+ | |||
+ | One great thing about the iDevices is that you can detect the orientation of the screen and rotate the content accordingly. Here is a way to do it in Sparrow. | ||
+ | |||
+ | In the ApplicationDelegate do this: | ||
+ | |||
+ | <code objc> | ||
+ | - (BOOL)shouldAutorotateToInterfaceOrientation: | ||
+ | { | ||
+ | return YES; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | In the SPStage class, in it's initWithWidth: | ||
+ | |||
+ | <code objc> | ||
+ | [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; | ||
+ | [[NSNotificationCenter defaultCenter] addObserver: | ||
+ | selector: | ||
+ | name: | ||
+ | </ | ||
+ | |||
+ | and add another method in this class: | ||
+ | |||
+ | <code objc> | ||
+ | -(void)onOrientationDidChange: | ||
+ | { | ||
+ | NSLog(@" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Whenever the device is now turned, the '' | ||