2012-04-10 55 views
0

我想使用自定義開機畫面,所以我在我的應用程序委託閃現屏幕圖像的方向不正確

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    // Override point for customization after application launch. 

    homeNavigationController = [[UINavigationController alloc] init]; 
    homeNavigationController.navigationBarHidden = NO; 

    [homeNavigationController pushViewController:viewController animated:NO]; 

    // Add the view controller's view to the window and display. 
    [window addSubview:homeNavigationController.view]; 
    [window makeKeyAndVisible]; 

    [self animateSplash]; 

    return YES; 
} 

- (void)animateSplash { 

    CGRect cgRect = [[UIScreen mainScreen] bounds]; 
    CGSize cgSize = cgRect.size; 

    // set default portrait for now, will be updated if necessary 
    NSString *imageName = @"splash_screen.png"; 
    CGRect imageFrame = CGRectMake(0, 0, cgSize.width, cgSize.height); 

    imageStage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]]; 
    imageStage.frame = imageFrame; 


    [window addSubview:imageStage]; 
    [window bringSubviewToFront:imageStage]; 

    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDelay:2]; 
    [UIView setAnimationDuration:3.0f]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)]; 

    imageStage.alpha = 0.0f; 

    [UIView commitAnimations]; 
} 

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 

    // remove and clean up splash image view 
    [imageStage removeFromSuperview]; 
    [imageStage release]; 
    imageStage = nil; 

} 

這項工作確定,但我的應用程序是在風景發射器(Home鍵右邊)模式,這樣做我的飛濺圖像方向設置不正確。

+1

請在發佈之前閱讀常見問題解答;您感興趣的特殊點:1.代碼格式化,2.使用頁腳。 – Till 2012-04-10 19:48:42

+1

肯定會這樣做,直到我新來StackOverflow :(將保重從下次 – a4arpan 2012-04-10 19:50:24

回答

1

只需使用旋轉後的圖像在您的方向上看起來正確即可。

如果您確實想在代碼中執行此操作,請查看How to Rotate a UIImage 90 degrees?以獲取旋轉UIImage的各種方法。

+0

非常感謝你亞當 – a4arpan 2012-04-11 08:25:33

0

你需要告訴iOS你想在橫向模式下啓動你的應用程序。您可以按照Apple here的指示來實現此目的。

+0

我已經在我的plist仍然說我的形象是不正確的旋轉屏幕 – a4arpan 2012-04-10 20:23:37

+0

你有設置爲LandscapeLeft或LandscapeRight? – jmstone617 2012-04-10 20:29:14

+0

風景(主頁右鍵) – a4arpan 2012-04-10 20:33:20