2011-05-20 68 views
1

我正在尝试使用phonegap探索ipad开发。我现在的问题是,Phonegap-ipad应用程序 - 调整根据方向启动图像

我有四个不同的发射图像不同的方向。当应用程序启动时,正在显示正确的启动图像片刻。在此之后,phonegap会尝试加载一个带有default.png的imageview并将其显示直到webview被完全加载。问题在于这里.. Imageview是基于当前方向自动旋转的。所以如果当前的方向是LandscapeLeft,imageview会在显示它之前尝试旋转default.png这不是我想要的,这就是为什么我有不同的启动图像。所以实际上,您将有一个landscapeleft.png,然后自动旋转default.png才能看到webview。

所以我试图改变这样的phonegapdelegate(在的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 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default7" ofType:@"png"]]; 
} 
imageView = [[UIImageView alloc] initWithImage:image]; 
[image release]; 

它没有工作和调试时我发现statusbarorientation总是肖像。这可能是因为phonegap尝试将肖像设置为同一个applicationDidFinishLaunching方法中的状态方向(在加载此图像视图之前)。

有人能告诉我如何以正确的图像加载图像视图?

回答

0

applicationDidFinishLaunching为应用程序接收来自操作系统的方向更改通知还为时尚早。因此,您无法在此确定方向。

所以,最佳的解决方案是做在能够确定当前orientaion.In我的情况下的生命周期阶段,webViewDidStartLoading

相关问题