开发者

Phonegap-ipad app -Adjust Launch image acc to Orientation

I am trying to explore ipad dev using phonegap. The problem that i have now is,

I have four different launch images for different orientations. When the app is launched, the correct launch image is being shown for a moment. After this,phonegap tries to load a imageview with default.png and displays it till webview is fully loaded. The problem lies here.. The imageview is autorotated based on the current orientation. So if the current orientation is LandscapeLeft, imageview tries to rotate default.png before displaying it Which is not i wanted and that is why i have different launch images.So in effect, you will have a landscapeleft.png and then the auto-rotated default.png before i get to see the webview.

So i tried changing the phonegapdelegate like this (in applicationDidFinishLaunching)

UIImage* image=nil;
if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight ){
    NSLog(@"In default5");
    image = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default5" ofType:@"png"]];
}
if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft ){
    NSLog(@"In default6");
    image = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default6" ofType:@"png"]];
}

if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown ){
    NSLog(@"In default7");
    image = [[U开发者_StackOverflow社区IImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default7" ofType:@"png"]];
}
imageView = [[UIImageView alloc] initWithImage:image];
[image release];

It didn't work and upon debugging i found that the statusbarorientation is always portrait. That may be because phonegap tries to set portrait as the statusbarorientation in the same applicationDidFinishLaunching method(before loading this image view).

Can someone tell me how to load the image view with correct image?


USE THESE NAMES:

  • Default-LandscapeLeft-ipad.Png
  • Default-LandscapeRight-ipad.Png
  • Default-Portrait-ipad.Png
  • Default-PortraitUpsideDown-ipad.Png

More: http://www.weston-fl.com/blog/?p=840


applicationDidFinishLaunching is too early for the app to receive orientation change notifications from the os. Hence you cannot determine the orientation here.

So the best possible solution is to do it in a lifecycle stage which is capable of determining the current orientaion.In my case, webViewDidStartLoading

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜