1

我用来UIImagePickerController拍照。 我在MainViewController中为UIApplicationDidBecomeActiveNotificationUIApplicationWillResignActiveNotification注册了一个通知中心

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc addObserver:self
           selector:@selector(applicationUIDidBecomeActive:)
               name:UIApplicationDidBecomeActiveNotification
             object:nil];

    [nc addObserver:self
           selector:@selector(applicationUIWillResignActive:)
               name:UIApplicationWillResignActiveNotification
             object:nil];

我有CamController,它是UIImagePickerController

@interface CamController : UIImagePickerController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

当应用程序确实激活时,我将根据 MainViewContrller 中的代码显示模态视图控制器。

- (void) applicationUIDidBecomeActive: (NSNotification *) aNotification {
    // camController is a instance of CamController
    [camController displayModalWithController:parentViewController animated:NO];
    [camController performSelector:@selector(takePicture) withObject:nil afterDelay:1.5];
}

下面的代码在 CamController 中,它是UIImagePickerController

- (void) displayModalWithController: (UIViewController*) aController animated: (BOOL) aAnimated {   
    if (aController) 
        [aController presentModalViewController:self animated:aAnimated];       
}

- (void) takePicture {
    [super takePicture];
}

- (void)imagePickerController: (UIImagePickerController *) aPicker didFinishPickingMediaWithInfo: (NSDictionary *) aInfo {  
    [self performSelector:@selector(takePicture) withObject:nil afterDelay:[self mCapturingInterval]];
}

当应用程序将退出活动时,我根据 MainViewController 中的代码关闭模式视图控制器。

- (void) applicationUIWillResignActive: (NSNotification *) aNotification {
    [parentViewController dismissModalViewControllerAnimated:NO];
}

我在 iphone 4 ios 4.2.1 上测试此代码,有时在我重新启动应用程序后,UIImagePicker 的视图(显示我们要捕获的图像的视图)被调整为更小,而不是全屏。我已经将属性 wantFullScreenLayout 设置为 YES。当我单击主页按钮将其置于后台,然后单击应用程序图标再次启动应用程序时,屏幕可能是全屏或调整大小。这个问题的原因是什么?

4

0 回答 0