cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Clelland <iclell...@google.com>
Subject Re: iOS: shouldRotateToOrientation javascript handler
Date Fri, 05 Jul 2013 15:20:59 GMT
I'm not sure what you mean by "Undocumented" in this case -- it's not a
private API that would get you booted from the App Store; it's a documented
method on UIView, although it's been deprecated recently.[1]

Agreed that supporting the screen-orientation spec is probably the way to
go in the future, on any platforms that can support it.

[1]
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#jumpTo_9


On Fri, Jul 5, 2013 at 10:18 AM, Michal Mocny <mmocny@google.com> wrote:

> iOS seems to have an undocumented "feature" to call into javascript before
> every device orientation change (pasted below for your viewing pleasure).
>
> I can't find any such similar functionality on other platforms, should it
> be removed?  Likely we will want to write a screen orientation (
> http://www.w3.org/TR/screen-orientation/) plugin instead (eventually).
>
>
> -
>
> (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
> {
>     // First, ask the webview via JS if it supports the new orientation
>     NSString* jsCall = [NSString stringWithFormat:
>         @"window.shouldRotateToOrientation &&
> window.shouldRotateToOrientation(%d);"
>         , [self mapIosOrientationToJsOrientation:interfaceOrientation]];
>     NSString* res = [webView
> stringByEvaluatingJavaScriptFromString:jsCall];
>
>     if ([res length] > 0) {
>         return [res boolValue];
>     }
>
>     // if js did not handle the new orientation (no return value), use
> values from the plist (via supportedOrientations)
>     return [self supportsOrientation:interfaceOrientation];
> }
>
> -Michal
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message