Skip to content

Commit

Permalink
LukeIS: adding GET orientation to iOS, but it doesn't like to work of…
Browse files Browse the repository at this point in the history
…f the bat, seems you must change your orientation and then it'll start working as expected

r16734
  • Loading branch information
lukeis committed Apr 26, 2012
1 parent 7f401db commit 02e8746
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions iphone/src/objc/Session.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ - (id) initWithSessionRootAndSessionId:(SessionRoot*)root
POST:NULL
withName:@"window_handles"];

// Get current orientation
// note not implementing the POST because the simulator and iphone
// can not be programmatically rotated via the api (that i can see)
[self setResourceToViewMethodGET:@selector(currentOrientation)
POST:NULL
withName:@"orientation"];

// switch to window
[self setResourceToViewMethodGET:NULL
POST:@selector(window:)
Expand Down
18 changes: 18 additions & 0 deletions iphone/src/objc/WebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,24 @@ -(NSArray*)windowHandles {
return [[NSArray alloc] initWithObjects:@"1", nil];
}

// Return the device's current orientation as a string
-(NSString*)currentOrientation {

if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {

return @"LANDSCAPE";
}
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)) {

return @"PORTRAIT";
}
// I'm not sure why but the initial state of the app seems to set the current orientation
// to unknown (0). Will hopefully look into this in the near future ;) TODO (lukeis)
return @"UNKNOWN";
}

-(void)window:(NSDictionary*)ignored {
// window switching isn't supported
return;
Expand Down

0 comments on commit 02e8746

Please sign in to comment.