2011-04-15 71 views
1

我發生了一件非常奇怪的事情。在我的應用程序委託中,我調用了presentModalViewController:在UITabBarController上顯示實現loadView以顯示圖像的自定義類(LoadingViewController)。當我在模擬器中對iOS 4.x設備(iPhone或iPad)進行測試時,它在任何方向都能正常工作。但是,當我測試3.2版iPad時,如果方向是縱向,它只能正常工作。如果是風景,則不會返回presentModalViewController:方法。 loadView和viewDidLoad方法被調用,但viewWillAppear:和viewDidAppear:方法不被調用。presentModalViewController:不返回

任何想法?

下面是LoadingViewController爲的loadView代碼:

- (void) loadView 
{ 
    CGRect mainScreenBounds = [UIScreen mainScreen].bounds; 

    UIImageView * loadingImageView = [[UIImageView alloc] initWithFrame: mainScreenBounds]; 

    loadingImageView.autoresizesSubviews = YES; 
    loadingImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

    NSString * splashImageName = [self getSplashImageName: [UIDevice currentDevice].orientation]; 
    loadingImageView.image = [UIImage imageNamed: splashImageName]; 

    UIActivityIndicatorView * spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge]; 
    CGRect spinnerFrame = spinner.frame; 

    spinnerFrame.origin.x = (mainScreenBounds.size.width - spinnerFrame.size.width)/2; 
    spinnerFrame.origin.y = mainScreenBounds.size.height * 0.7f; 

    spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin 
          | UIViewAutoresizingFlexibleRightMargin 
          | UIViewAutoresizingFlexibleTopMargin 
          | UIViewAutoresizingFlexibleBottomMargin; 
    spinner.frame = spinnerFrame; 
    spinner.hidesWhenStopped = YES; 

    [spinner startAnimating]; 

    [loadingImageView addSubview: spinner]; 

    // Add a label indicating we are working so the user knows what we are doing. 
    UIColor * textColor = [UIColor blueColor]; 

    CGRect labelFrame = loadingImageView.frame; 
    labelFrame.size.height = 40; 
    labelFrame.origin.y = spinnerFrame.origin.y - 100; 
    UILabel * workingLabel = [[UILabel alloc] initWithFrame: labelFrame]; 
    workingLabel.font    = [UIFont systemFontOfSize: 18.0]; 
    workingLabel.textColor  = textColor; 
    workingLabel.backgroundColor = [UIColor clearColor]; 
    workingLabel.textAlignment = UITextAlignmentCenter; 
    workingLabel.text    = NSLocalizedString(@"Searching for location...", @"Searching for location..."); 
    workingLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin 
            | UIViewAutoresizingFlexibleRightMargin 
            | UIViewAutoresizingFlexibleTopMargin 
            | UIViewAutoresizingFlexibleBottomMargin 
            | UIViewAutoresizingFlexibleWidth 
            | UIViewAutoresizingFlexibleHeight; 

    [loadingImageView addSubview: workingLabel]; 
    [workingLabel release]; 

    [spinner release]; 

    self.view = loadingImageView; 
    [loadingImageView release]; 
} 

回答

0

我們最終的解決方案是根本不使用presentModalViewController,而是將LoadingViewController設置爲根視圖控制器。顯然這不是一個完整的解決方案,但幸運的是,它對我們來說足夠好。有什麼令人沮喪的是不知道爲什麼presentModalViewController現在無法正常工作,當它在我們的應用程序的先前版本中正常工作時。我們已經做了一些破壞它的事情。

0

在使用presentModalViewController.此外,在景觀帶的UITabBarController使用presentModalViewController時有一個與IOS 3.2一個問題的UITabBarController應該是RootViewController的,如果所有它的viewcontrollers不要」 t覆蓋shouldAutorotateToInterfaceOrientation並且爲橫向返回yes,則會導致presentModalViewController掛起。