Image Picker的视图意外调整大小

时间:2012-09-11 05:26:41

标签: iphone objective-c uiimagepickercontroller presentmodalviewcontroller

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

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的视图(显示我们要捕获的图像的视图)被调整为更小, 不再是全屏了。我已经将属性wantsFullScreenLayout设置为YES。 当我单击主页按钮将其置于后台然后单击应用程序图标以再次启动应用程序时,屏幕可能是全屏或 调整大小。这个问题的原因是什么?

0 个答案:

没有答案